0

Suppose my file name is äbc def

When I type in the terminal like cat ¨abc def¨ it shows error. Can anybody tell me how to print this file that has spaces in between the name.

1
  • 4
    What is the error you're seeing? And include the exact command. Use copy&paste and also include the directory listing... ls -l. Edit your question to include these details.
    – gertvdijk
    Aug 27, 2013 at 19:12

2 Answers 2

3

By ¨abc def¨ do you mean "abc def"?

You can do two things. You can either put a \ in front of the space to tell bash that the next character is a literal space in the file name, like this,

cat abc\ def

Or, you can place the file name in single-quote (') or double quote (") characters:

cat 'abc def'

or

cat "abc def"

If you use tab autocompletion, the first method will automatically be used.

I hope this answers your question.

3
  • 1
    double quotes work as well and the auto-completion should work too.
    – Symin
    Aug 27, 2013 at 20:04
  • Ok, I will edit that in.
    – Richard
    Aug 27, 2013 at 20:44
  • 1
    Also you can use cat or any other command and then drag (a) file/s directly into terminal. Terminal will then plot the path/dir of this file, also considering the space within the files name.
    – v2r
    Aug 27, 2013 at 21:08
0

Try this

cat abc\ def

Normally, to make Ubuntu understand the space you need to use "\" before space.

You must log in to answer this question.

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