Skip to Content
Ubuntu: Up and Running
book

Ubuntu: Up and Running

by Robin Nixon
April 2010
Beginner
464 pages
12h 7m
English
O'Reilly Media, Inc.
Content preview from Ubuntu: Up and Running

Using Quotation Marks

With the Nautilus file manager, it is easy to create files and folders that include spaces in their names. You can also copy and move these about by dragging and dropping them without any problem.

But when you come to access such files from the command line, you must remember to enclose them in quotation marks. For example, if your username is jenny and you have a folder called My Projects in your home folder that you would like to access from the command line, you cannot use the cd command in the normal way, like this:

cd /home/jenny/My Projects

The reason is that Ubuntu will think you want to change to a folder called /home/jenny/My and will report the following error:

bash: cd: /home/jenny/My: No such file or directory

To prevent this, the correct way to change to such a folder is to enter the following, with double quotation marks (or you can use single quotation marks instead if you prefer):

cd "/home/jenny/My Projects"

Likewise, using any other Bash commands with spaces in file or folder names requires similar use of quotation marks. The following collection of commands all illustrate the correct way to handle spaces in folder and filenames:

mkdir "/home/jenny/My Projects"
cd ~/"My Projects"
ls -al "/home/jenny/My Projects/January"
rm "Backups/Old|Report.doc"

The fourth line doesn’t have any spaces but it still requires the use of quotation marks. The reason is that the | character—which, like the space, is a normal character when used on the desktop—is a special ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ubuntu Made Easy

Ubuntu Made Easy

Rickford Grant, Phil Bull
Ubuntu for Non-Geeks, 4th Edition

Ubuntu for Non-Geeks, 4th Edition

Rickford Grant, Phil Bull

Publisher Resources

ISBN: 9781449382827Errata Page