Terminal Text

~/LALALA $ dir
la\ la\ 1 la\ la\ 2

Directory Image

Directory Image

When I use dir command in terminal, the list of file show \ (backslash) to separate their word (see: Terimanal Image). Whereas in the origin, there is no '\' (backslash) (see: Directory Image). How do I change this back to normal?

NB. I think the reason is because of the pwd command on the terminal. After I use the PWD command, this happens.

  • 2
    The backslashes are escaping the spaces in the names. It might be easier to see with the option -l "space minus ell": Try with dir -l or ls -l – sudodus Nov 21 '19 at 8:13

What you experience is quoting, dir has the -N or --literal option to disable it:

-N, --literal
       print entry names without quoting

The exact same applies to ls, just that it quotes the whole filenames with single quotes instead of escaping special characters (which can be triggered with -b or --escape for ls as well). Calling ls with -N disables this behaviour as well.

Example run

$ touch 'la la '{1,2}
$ dir
la\ la\ 1  la\ la\ 2
$ dir -N
la la 1  la la 2
$ ls
'la la 1'  'la la 2'
$ ls -b
la\ la\ 1  la\ la\ 2
$ ls -N
la la 1  la la 2

Further reading


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.