Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I don't know why but when I go to change this file name with mv command it comes up with the error stating not a directory.

-bash-4.1# mv {{ THEME SANITIZED }}.hacks.css myomega.hacks.css

share|improve this question
    
Do you have spaces in your file name? –  Ramesh Mar 27 at 1:18

3 Answers 3

up vote 3 down vote accepted

mv "{{ THEME SANITIZED }}.hacks.css" myomega.hacks.css will work.

share|improve this answer
    
WORKS! thanks for that. –  cea Mar 27 at 1:23
    
have to wait 6 minutes to give you the answer which is stupid! –  cea Mar 27 at 1:23
    
Glad it worked :) No problem :) –  Ramesh Mar 27 at 1:24

you can use double quotes to scape or scape with slash like for example:
using double quotes:

mv "{{ THEME SANITIZED }}.hacks.css" myomega.hacks.css

using slash:

mv \{\{\ THEME\ SANITIZED\ \}\}.hacks.css myomega.hacks.css

something cool that some people doesn't know how to remove ou rename a directory when it's start with dash you can you dash dash :D
exemple:

mkdir -directory_with_dash
rm -r -- -directory_with_dash
share|improve this answer
    
Interesting. Where would I find such information in a book- does this pertain to LINUX only? –  cea Mar 27 at 3:47

You need to tell the shell that you mean for the braces and spaces to be part of the file name, instead of being interpreted as shell syntax.

You can type file names containing special characters inside single quotes. This works for every character except the single quote itself. This is the easiest method in a script.

mv '{{ THEME SANITIZED }}.hacks.css' myomega.hacks.css

If you need a single quote inside a single-quoted string, you can use the four-character sequence '\''.

mv 'It'\'s' wierd' this_is_weird

Alternatively, you can put a backslash before any character, which makes it lose its special meaning. It doesn't hurt to put a backslash before characters that have no special meaning, but it's of course extra unnecessary typing.

mv \{\{\ THEME\ SANITIZED\ \}\}.hacks.css myomega.hacks.css

If the file name comes from a variable, use double quotes around the variable expansion to preserve special characters (with a bare variable as in mv $source $destination, some special characters in the value of the variable are expanded).

source='{{ THEME SANITIZED }}.hacks.css'
destination=myomega.hacks.css
mv "$source" "$destination"

On the command line, the easiest way to type such a file name is to rely on completion. You'll need to enter at least the first character, then press Tab.

mv \{Tab
mv \{\{\ THEME\ SANITIZED\ \}\}.hacks.css 

share|improve this answer
    
ThANKS FOR THAT COMPREHENSIVE EXPLANATION! –  cea Mar 28 at 2:58

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.