Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] How to cope with strange filenames in bash?



Michal Hajek wrote:

 > how do I cope in bash with filenames containing "-" character (i.e.
 > dash) ? 

 > In my case, I have downloaded this file:  
 > -umai-Doremi--Kenichi-10--B36CAB67-.avi.part1.rar
 
   [brief snip]

 > $ mv \-umai\-Doremi\-\-Kenichi\-10\-\-B36CAB67\-.avi.part1.rar k1.rar
 > mv: invalid option -- m
 > Try `mv --help' for more information.

  There may well be a very simple escaping sequence that I'm
missing, but one way around this is via the "find" command. 
("The find Command Is Great" [1]).

    find . -name "*Doremi--Kenichi*" -exec mv {}  k1.rar \;

 This assumes that you've only got one file in the current
directory that has got "Doremi--Kenichi" in the name. If not,
you can just spell out the file name in full in the quotes.
If the file isn't in the current directory, change the "." to
the directory name.


   The {} and the \; are both absolutely needed. 

       -Chris

[1] "UNIX Power Tools", 2nd Edition, p. 289. 

    The book is now in its 3rd edition, at least. I'd highly 
    advise picking up a copy as it's got great tips in there 
    that are often perfectly good for Linux as well.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links