$ grep alias ~/.bashrc # User specific aliases and functions . ~/.alias $ grep mydiff ~/.alias alias mydiff='diff --ignore-space-change --ignore-blank-lines --side-by-side --suppress-common-lines' $ alias mydiff alias mydiff='diff --ignore-space-change --ignore-blank-lines --side-by-side --suppress-common-lines' $ ssh -q localhost 'alias mydiff' alias mydiff='diff --ignore-space-change --ignore-blank-lines --side-by-side --suppress-common-lines' $ ssh -q localhost 'mydiff' bash: mydiff: command not found
为什么“mydiff”不能通过SSH获得? 谢谢
来自man bash(1) :
Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt (see the description of shopt under SHELL BUILTIN COMMANDS below).
.bashrc下行添加到您的.bashrc文件中:
shopt -s expand_aliases
要么:
[alexus@wcmisdlin02 ~]$ ssh 0 'bash -c ll | head -1' bash: ll: command not found [alexus@wcmisdlin02 ~]$ ssh 0 'bash -ci ll | head -1' bash: no job control in this shell total 8612 [alexus@wcmisdlin02 ~]$