The GNU versions can handle the
"whitespace in the directory name" problems:
find / -name '*.gz' -size +1000k -print0 | xargs -0 rm -i
or
find / -name '*.gz' -size +1000k -print0 | xargs -0 -p -n 1 rm
Note the -print0 switch on the
find and the -0
switch on the xargs command.
| [reply] [d/l] [select] |
Since you brought this point up more than once, i'm just
wondering where are typical settings where you see spaces
in filenames?
(it is so rare for me that i usually just don't think about it)
thanks,
ff | [reply] |
That is a classic stupid user trick. :-)
Honestly, programmers tend to be aware in their gut of the problems you could get into with spaces and Don't Do That. But end users blithely type "My Personal Stuff" into the GUI and then wonder much later why something broke.
Oh, and Microsoft does it as well. For example "Program Files". "My Computer".
I have seen them be burned by it as well. I forget which vesion of IE and Excel, but if you were on a computer where temporary internet files went into a path with spaces (for instance, c:\\WINNT\Temporary Internet Files) and you passed them a .csv file from a CGI script with arguments (a url like http://yoursite/yourpath/some.cgi/nicename.csv?month=200004) then it would break the path to the temporary downloaded file into components and try to launch Excel multiple times, one per component.
Oops.
This is why real data structures are safer than constantly parsing and reparsing text like shell scripts do.
| [reply] |
It takes only one to ruin your day:
$ mkdir -p "/tmp/fool
/etc"
$ touch "/tmp/fool
/etc/passwd"
Then kick back and wait for the nightly root cronjob to clean up /tmp.
-- Randal L. Schwartz, Perl hacker | [reply] [d/l] |