为什么屏幕看不到我的别名?

为什么屏幕看不到我的别名?

我有这个别名.bashrc

...
...
alias server1='for line in `seq 1 10`; do echo "Running server 1: "$line; sleep 1; done'

server1命令在终端中可以正常工作。但我想知道为什么我无法通过运行以下命令来启动它:

screen -S S1_Screen -m server1

当我尝试时,我得到Cannot exec 'server1': No such file or directory

但是当我像这样启动一个屏幕screen -S S1_Screen,然后server1在其中手动运行时,它工作正常。为什么当我运行时屏幕看不到我的别名screen -S S1_Screen -m server1

答案1

man bash

Aliases allow a string to be substituted for a word when it is used as the first
word of a simple  command.The shell maintains a list of aliases that may be
set and unset with the alias and unalias builtin commands (see SHELL BUILTIN
COMMANDS below). The first word of each simple command, if unquoted, is checked
to see if it has an alias. If so, that word is replaced by the text of the alias.

你的命令中的第一个词screen -S S1_Screen -m server1screen,不是server1

相关内容