Why is my alias now not working?
13,492
Solution 1
Use double quotes instead of single quotes:
alias newcommand="full path of the binary to be executed"
and not:
alias newcommand='full path of the binary to be executed'
No space near equal either on the left or on the right.
Solution 2
You have a space between the =
and the opening '
. Remove it.
$ alias foo= 'bar baz'
bash: alias: bar baz: not found
Related videos on Youtube
Author by
thinksinbinary
Updated on September 18, 2022Comments
-
thinksinbinary over 1 year
So before I reformatted (to get rid of Windows), I simply used this command to open documents by putting it at the end of the
~/.bashrc
file:alias commandless= 'gnome-open ./Documents/the-linux-command-line.pdf; gnome-open ./Documents/linux.odt'
But now everytime I start the terminal, it says:
bash: alias: gnome-open ./Documents/the-linux-command-line.pdf; gnome-open ./Documents/linux.odt: not found
before even typing anything in, and when I run the command nothing happens, not even error messages.
-
andruso about 4 yearsthinksinbinary, please accept the correct answer, it would help future readers.
-
-
AVS over 8 yearsThere should not be any space between equal to
-
thinksinbinary over 8 yearsno, ABISHEK appears to be right, i had to remove the space and put in the quotes instead of the apostrophe
-
kos over 8 yearsThat I'm afraid still doesn't make the "use double-quotes" suggestion right. If you want to remove it, since it's wrong and misleading, I'll remove my downvote, however there's another answer pointing out the space problem which was posted 45 minutes before yours, so your answer is (aside from the single / double quotes thing) basically identical to the answer already present. It doesn't really add anything new.
-
fiatux over 8 yearsEspecially with bash -- it parses the commands into tokens by whitespace, so it's extremely sensitive to stray spaces.
-
AVS over 8 yearsIf it still does not work then replace gnome-open with its full executable path. You can use which gnome-open or whereis gnome-open to get the complete path
-
thinksinbinary over 8 yearskos- perhaps my os is different but i tried with the single quotes and it does not work