Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a file named +13x18_DSC_0800.JPG on a linux server (Please don't ask me how it got there as I have no idea how it got there). I wish to rename it to 13x18_DSC_0800.JPG. However I have not been able to. When I try to copy it I get ;

# cp \+13x18_DSC_0800.JPG asd.JPG
  cp: cannot stat `+13x18_DSC_0800.JPG': No such file or directory

Here is some more inforamtion ;

#ll
 -rwxrwxrwx  1 ftpuser renko 2798985 2011-10-14 01:12  +13x18_DSC_0800.JPG*

I really don't know what is wrong other than that the plus sign is killing some script. Some more information ;

#uname -a
Linux server-1 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

Any help would be awesome...

share|improve this question

4 Answers 4

up vote 3 down vote accepted

Often this means there are some non-printing characters in the filename, which you can't see because they're non-printing.

Try ls -la > /tmp/foo then vi -b /tmp/foo to look at all the text.

If that's the case, the easiest way is to handle it via glob, try echo *13x18_DSC_0800* to verify that the glob matches that file (and only that file), then you can do mv *13x18_DSC_0800* newname.jpeg to rename it.

share|improve this answer
    
Or ls -la | cat -vT –  Janne Pikkarainen Dec 5 '11 at 10:33
    
@MadHatter I got a "-rwxrwxrwx 1 ftpuser renko 2798985 2011-10-14 01:12 +13x18_DSC_0800.JPG -rwxrwxrwx 1 ftpuser renko 2567144 2011-10-14 01:12 +13x18_DSC_0848.JPG " –  JohnRoach Dec 5 '11 at 10:40
    
@MadHatter Although I haven't been able to resolve this issue without using the joker card i.e. "". Here is the solution I have been able to find ; #cp *DSC_0800 13x18_DSC_0800.JPG #rm + This seems to do the trick... I still wonder why I couldn't do it without using the * .... Since you reminded me of the * you get the bonus! –  JohnRoach Dec 5 '11 at 10:49

For me

    cp +13x18_DSC_0800.JPG 13x18_DSC_0800.JPG

worked like charm, without any escaping.

share|improve this answer

stupid and simple solution if you want to get rid of just one file - use midnight commander :D

but + sign at the beginning shouldn't be a problem at all ...

    $ touch +13x18_DSC_0800.JPG
    $ mv +13x18_DSC_0800.JPG test.jpg
    $ rm test.jpg

works for me ...

share|improve this answer
    
[edited] actually it did not work... the test.jpg turned out to be a 0 byte file... –  JohnRoach Dec 5 '11 at 10:36
1  
touch does create an empty file with that name if it does not exist. i was presenting this as an example of it working. –  Fox Dec 5 '11 at 10:42

Use

cp "+13x18_DSC_0800.JPG" 13x18_DSC_0800.JPG
share|improve this answer
    
Sorry but no cigar you get a : "cp: cannot stat `+13x18_DSC_0800.JPG': No such file or directory" error –  JohnRoach Dec 5 '11 at 10:35

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.