Earlier quoted context omitted.
find ./ -name '*.log' -print0 | xargs -0 rm Fixes that issue and xargs is far more efficient, it doesn't launch a new process for each line like exec does, but far more importantly, xargs is generalizable to all commands so you only have to learn it once; exec is just an ugly hack on find, you can't generalize it across all commands; xargs is much more unixy.
> it doesn't launch a new process for each line like exec does Exec doesn't either if you use "+" as a terminator: find . $(options) -exec command {} \; executes one command per match, find . $(options) -exec command {} + executes a single command with all matches > exec is just an ugly hack on find Obvious and complete nonsense, -exec is both an important predicate of find and a useful and efficient tool. -print0/xa…
Unix Commands I Abuse Every Day
101–108 of 108 posts
Re: Unix Commands I Abuse Every Day
#102Earlier quoted context omitted.
> it doesn't launch a new process for each line like exec does Exec doesn't either if you use "+" as a terminator: find . $(options) -exec command {} \; executes one command per match, find . $(options) -exec command {} + executes a single command with all matches > exec is just an ugly hack on find Obvious and complete nonsense, -exec is both an important predicate of find and a useful and efficient tool. -print0/xa…
You apparently missed the part where I said "but far more importantly".
Re: Unix Commands I Abuse Every Day
#103Earlier quoted context omitted.
Wanting to remove the files was so common that some finds have it built-in. Avoids even the overhead of -exec rm {} +. find -name '*.log' -delete
True, but the issue isn't removing files, the issue is generalizing a command for mapping output of a command to another command. rm was just a simple example. xargs is far more useful than simply deleting files.
Re: Unix Commands I Abuse Every Day
#104Earlier quoted context omitted.
It's most definitely catenate. I understand catenate to mean chain and concatenate to be to chain together. Since "cat foo bar xyzzy" doesn't modify the files to join them in any way I don't think they're chained together. Besides, ken & Co. aren't daft. con would be short for concatenate. :-)
According to the 1st Edition and 6th Edition manual pages: NAME cat -- concatenate and print See: http://man.cat-v.org/unix-1st/1/cat http://man.cat-v.org/unix-6th/1/cat I'm pretty sure based on the timeline of pipe (~1973, roughly V4) that the cat command (~1971 V1) predates pipes.
Re: Unix Commands I Abuse Every Day
#105It's a newish feature of less (those of you with stale RHEL installs won't find it). Type '&' and you'll filter down a listing to match pattern. Regexes supported. Prefixed '!' negates filter.
Wishlist: interactive filter editing (similar to mutt's mail index view filters), so you don't have to re-type full expressions.
Re: Unix Commands I Abuse Every Day
#106Earlier quoted context omitted.
You apparently missed the part where I said "but far more importantly".
No, that's just your opinion and you're entitled to it so I don't care, the rest is factually incorrect.
Re: Unix Commands I Abuse Every Day
#107Earlier quoted context omitted.
True, but the issue isn't removing files, the issue is generalizing a command for mapping output of a command to another command. rm was just a simple example. xargs is far more useful than simply deleting files.
Removing files is a common need coupled with find yet many readers don't know of -delete; I was pointing it out. That doesn't weaken xargs's valid uses. You seem a little defensive? :-)
Re: Unix Commands I Abuse Every Day
#108 tar -tf tarfile.tar | xargs rm
Witless uninstall #2. Find a file that you changed just before "make install" into the wrong spot (usually config.log is a good candidate). find /bogus/installdir -newer config.log | xargs rm
Yes, this is totally unsafe. But it's an abuse... so, there you go