3
$ 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

Why is "mydiff" not available through SSH? Thank you

1 Answer 1

3

from 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).

add the following line to your .bashrc file:

shopt -s expand_aliases

or:

[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 ~]$ 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .