Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
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 '13 at 19:12
add comment

2 Answers 2

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.

share|improve this answer
1  
double quotes work as well and the auto-completion should work too. –  Symin Aug 27 '13 at 20:04
    
Ok, I will edit that in. –  Richard Aug 27 '13 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 '13 at 21:08
add comment

Try this

cat abc\ def

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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