Whats the difference between commands:-

  1. ls
  2. \ls

So if i write


Whats the difference?


The backslash will force the ls command to be used without any aliasing.

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.