0

If I have the following line in .bash_profile:

alias j="ls -ltr"

Then I type j at the command prompt, the output is as expected. But if I put the alias command in a separate file, and source it from .bash_profile:

source ./aliases

or

. ./aliases

Then type j at the command prompt, the output is:

's: invalid option -- '
Try 'ls --help' for more information.

I have tried various ways of quoting and escaping. I do not know why it is different when the alias command is sourced from a separate file. The output of uname -a is:

Linux vbox4rhel 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 8 13:30:15 EST 2021 x86_64 x86_64 x86_64 GNU/Linux

I would like to know what is different when the alias command is in a separate file that is sourced. Thanks.

Nic3500
  • 8,144
  • 10
  • 29
  • 40
  • 3
    The garbled error message indicates that your `aliases` file is in DOS/Windows format, which can cause all sorts of trouble. See ["Are shell scripts sensitive to encoding and line endings?"](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) – Gordon Davisson Nov 25 '21 at 18:57
  • Thanks. I don't see anything to click on to accept the answer, but that was the correct answer. – Paul CyberCitizen Nov 26 '21 at 01:31
  • Check my edit, it will show you how to format code and/or commands in questions. – Nic3500 Nov 26 '21 at 02:58

0 Answers0