Bash: dealing with spaces in filenames

Well, this is a n00bish thing but it kind of puzzled me for a while. In a portuguese (either pt-PT or pt-BR) locale Ubuntu installation, and I guess in other distributions, the Desktop folder is inconveniently named ‘Área de Trabalho’. Not only it is a pain in the neck to write it down in the shell, but also when writing bash scripts that will deal with it. However, the solution is simple:

For the first pain in the neck, just link Área de Trabalho to Desktop with:

ln -s Área\ de\ Trabalho/ Desktop

For the second, just escape the variable name enclosing it in commas:

ln -s "$PWD"/cgi-bin $CGI/test

Hope it helps anyone

One thought on “Bash: dealing with spaces in filenames

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s