8

Terminal Text

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

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.

Eliah Kagan
  • 117,780
  • 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 08:13

1 Answers1

11

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

Eliah Kagan
  • 117,780
dessert
  • 39,982