为什么我的别名现在不起作用?

thi*_*ary 5 command-line alias

因此,在我重新格式化(以摆脱 Windows)之前,我只是使用此命令通过将其放在~/.bashrc文件末尾来打开文档:

alias commandless= 'gnome-open ./Documents/the-linux-command-line.pdf; gnome-open ./Documents/linux.odt'
Run Code Online (Sandbox Code Playgroud)

但是现在每次我启动终端时,它都会说:

bash: alias: gnome-open ./Documents/the-linux-command-line.pdf; gnome-open ./Documents/linux.odt: not found
Run Code Online (Sandbox Code Playgroud)

在输入任何内容之前,当我运行命令时什么也没有发生,甚至没有错误消息。

gle*_*man 25

=和开口之间有一个空间'。去掉它。

$ alias foo= 'bar baz'
bash: alias: bar baz: not found
Run Code Online (Sandbox Code Playgroud)


小智 -2

使用双引号代替单引号:

alias newcommand="full path of the binary to be executed"
Run Code Online (Sandbox Code Playgroud)

并不是:

alias newcommand='full path of the binary to be executed'
Run Code Online (Sandbox Code Playgroud)

左侧或右侧没有几乎相等的空间。

  • 在这种情况下,使用双引号不会改变任何内容,问题是“=”后面的空格 (8认同)
  • @thinksinbinary 双引号绝对是不必要的。尝试使用单引号,无论如何它仍然有效。 (4认同)
  • 恐怕仍然不能使“使用双引号”建议正确。如果你想删除它,因为它是错误的和误导性的,我会删除我的否决票,但是还有另一个答案指出了空间问题,该问题是在你的答案之前 45 分钟发布的,所以你的答案是(除了单引号/双引号之外) )与已经存在的答案基本相同。它并没有真正添加任何新内容。 (2认同)