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

Re: Bash script question

The '-print0' of 'find' and the '-0' of 'xargs' (those are the number zero, not a capital o) prevent problems processing file names that contain white space (such as you might get from other OS's, but can also get on UNIX/Linux systems when using GUI programs that create files).

It uses a 'null' character (ASCII 0x0000) to terminate the character sequence that is the file name. Note, in the documentation, it specifically talks about embedded newlines in file names, then mentions other white space.

FYI, the documentation of 'find' explains this clearly.


H.S. wrote:
Stephen R Laniel wrote:

The easiest way wouldn't involve the filename at all. If you
know that a file created on date D is stamped with date D --
i.e., if your files all look like so:

(13:09) slaniel@whitehail:~$ ls filename-20061207.tar.gz -rw-r--r-- 1 slaniel slaniel 0 2006-12-07 13:09 filename-20061207.tar.gz

-- then you can just use find(1). You could do something

find directoryName -mtime +X -print0 |xargs -0 rm '{}'

just a related questions, how is the above different from:
$> find directoryName -mtime +X -exec rm -f  '{}' \;


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply to: