logoalt Hacker News

chasilyesterday at 11:53 PM3 repliesview on HN

I use:

  find . -name '*.log' -print0 | xargs -0 rm
For this simple example (derived from the article), find also has a delete operator.

This null termination is now a POSIX standard.


Replies

ivladtoday at 12:07 AM

Was exactly my thought: why not to use null termination?

Looks like a case where reading man page would have spared writing another copycat utility.

show 1 reply
Walftoday at 1:26 AM

Yeah, and I invariably add -r to xargs, so as not to execute the command unless results come through the pipeline.

If one is working with whole lines of text, setting the delimiter to newline is often desirable:

xargs -d \\n