Whats the difference between commands:-
So if i write
$ls or $\ls
Whats the difference?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
The backslash will force the
ls command to be used without any aliasing.
In general, backslash suppresses expansion, except, confusingly, where it does C-like escaping of control characters.
In the first part of your question, sblair is right, the backslash suppresses aliasing, or alias expansion..
In the second part, the backslash suppresses dollar-expansion:
$ls expands to the current value of the
ls shell variable, whilst
$\ls is not expanded. So if
ls is not
set to anything,
echo $ls; echo $\ls will print a blank line (the contents of $ls) followed by
$ls on the next line.