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.

1
  • 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, 2019 at 8:13

1 Answer 1

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .