5

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.

1
  • thinksinbinary, please accept the correct answer, it would help future readers.
    – andruso
    Mar 10, 2020 at 7:15

2 Answers 2

25

You have a space between the = and the opening '. Remove it.

$ alias foo= 'bar baz'
bash: alias: bar baz: not found
1
  • 1
    Especially with bash -- it parses the commands into tokens by whitespace, so it's extremely sensitive to stray spaces. Oct 12, 2015 at 16:49
-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.

7
  • 8
    Using double-quotes doesn't change anything in this case, the problem is the space after the =
    – kos
    Oct 12, 2015 at 16:35
  • There should not be any space between equal to
    – AVS
    Oct 12, 2015 at 16:39
  • no, ABISHEK appears to be right, i had to remove the space and put in the quotes instead of the apostrophe Oct 12, 2015 at 16:45
  • 2
    That 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.
    – kos
    Oct 12, 2015 at 16:48
  • 4
    @thinksinbinary Double-quotes are definetly not necessary. Try using single quotes instead, it will still work regardless.
    – kos
    Oct 12, 2015 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.