-   Linux - Software (
-   -   Xargs and spaces in file path (

mgichoga 01-04-2008 11:30 AM

Xargs and spaces in file path
I'm trying to delete some mp3 from my backup server to free up some space and was using locate and xargs to do this. This works well except when there is a space in the file path. How can I pass the file path to xargs with quotes so the rm command can be able to parse the file path. this is what the command I'm issuing

locate *.mp3 | xargs rm

Dinithion 01-04-2008 11:59 AM

locate --print0 *.mp3 | xargs -0 -n 10 echo

I'm not sure if it will work. It works here in small scale, but when I push the whole locate trough, it gives a error msg. Anyway, the --print0 option sends a ascii0 at the end of the filename, and -0 option on xargs uses this null as a argument seperator. Finally -n limits the execution to 10 files at a time.

If it works, change echo with rm :)

Tinkster 01-04-2008 12:57 PM


locate \.mp3|xargs -i rm "{}"
might work .... (untested!)


All times are GMT -5. The time now is 10:43 AM.