Re: : bash script issue
"Stewart C. Russell" <[email protected]> Sun, 17 Aug 2014 14:49:34 -0400
| Newsgroups | gmane.org.user-groups.linux.tolug |
|---|---|
| Message-ID | <[email protected]> |
On 14-08-17 01:53 PM, William Muriithi wrote: > > What's a better way of handling such a file name? There are a million different ways of doing this, and the way I deal with difficult file names is treat them as separate records: find /home/wmuriithi/images/ -type f | while read f do mv "$f" /home/wmuriithi/archive/images/"$DATE"/ done or whatever you need to do. If you're in charge of creating the intermediate files, make your life easier from now on by not creating files with spaces in them in the first place. You can't guarantee that other people will be so careful, but your own work you can control. Those are only slightly ugly file names you are dealing with. Here's how to make a very special one: f=$(/bin/echo -e \-\ '\xe2\x98\xba'\$f\(a\:\ \\\\\'2\"\'\)\&.dat.bak\ ) date > "$f" This is an illegal file name on almost every other OS, and a spectacularly ill-advised one on Linux. For extra lulz, create distinct files based on that template, varying only in the upper/lower case of one letter. cheers, Stewart -- The Toronto Linux Users Group. Meetings: http://gtalug.org/ TLUG requests: Linux topics, No HTML, wrap text below 80 columns How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists