Saturday, 25 August 2012

Coping with funny file names

I thought that spaces and other odd things in file names was just an irritating Windows thing, but no, it appears the contagion is now part of linux too.

Both the Swiss-army-knife commands find and xargs will cope tho, with just a little tweaking:
find /myfolder -type f -size +1M -print0 | xargs -0 ls -l
Find, unsurprisingly finds a list of files matching a criteria. Xargs then does something with them. In this case we're just listing files bigger than 1 meg.

Slightly related to this is the challenge of removing files with odd file names. A good tip is the -i flag on rm:
rm -i c*

This will check with you for each file starting with c.

No comments:

Post a Comment