In a bash shell, why can't I create an alias
$ alias fooo="echo bac"
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
$ alias fooo='echo bac'
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
$ fooo
fooo: command not found
$ alias fooo
bash: alias: fooo: not found
In another bash shell, the above commands succeed in creating an alias
$ alias fooo="echo bac"
$ fooo
bac
In the first shell, if I start a new shell (just type bash
and press enter), or start a new login shell (type bash -l
), the above commands also succeed as in the second shell.
Regarding the reply on alias
command in the first shell
$ which alias
$ whereis alias
alias:
$ builtin alias fooo="echo bac"
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
$ type alias
alias is a shell builtin
$ type -a alias
alias is a shell builtin
$ unalias alias
bash: unalias: alias: not found
Regarding the comment on echo
in the first shell
$ echo hello
hello
$ whereis echo
echo: /bin/echo /usr/share/man/man1/echo.1.gz
$ which echo
/bin/echo
echo
. Is it disabled? – Tim Dec 18 '16 at 00:41alias
itself. – Julie Pelletier Dec 18 '16 at 03:19alias echo=''; alias fooo='echo bac'; fooo
– Julie Pelletier Dec 18 '16 at 03:20echo
withprintf
to see if it does the same thing. – Julie Pelletier Dec 18 '16 at 04:56type -a alias
and post output here. As there might be an alias on the word alias, also dounalias alias
. Post results here. Then, after trying all that. Are you typing onlyalias fooo="echo bac"
and getting all the output you posted?. What happens if you start a new shell in that console (just typebash
and press enter), do you still get the same output? What is you start a new login shell (typebash -l
)? Still in trouble?. – Dec 18 '16 at 05:02alias fooo
? and: What is the output ofalias fooo='echo bac'
? – Dec 18 '16 at 05:34bash
the command success, but: could you doalias fooo='echo bac'
in that new shell successfully? – Dec 18 '16 at 05:37alias fooo='echo bac'
or the whole list of all the aliases? – Dec 18 '16 at 05:42alias fooo='echo bac'
, but notalias -p
oralias
. – Tim Dec 18 '16 at 05:50alias fooo='echo bac'
and pressing enter, you get the long list of aliases (which also go away with a new shell). If that is the correct description of what you see, I can not explain it. I'll suggest to you to assume that that is an unreproducible problem (it doesn't happen here to me nor (it seems) to the other guys trying to help you) and so start a new shell and move on to other issues/tasks/problems. I must give up: can't help. – Dec 18 '16 at 05:58