[Techtalk] re: Joining commands together in bash

Malcolm Tredinnick malcolm at commsecure.com.au
Mon May 12 22:13:14 EST 2003


On Mon, May 12, 2003 at 10:00:10PM +1000, Malcolm Tredinnick wrote:
[...]
> Also both Meredydd's and my solutions fail on filenames with spaces in
> them. Meredydd's version can be fixed, but I think my one requires some
> trickery with xargs that I cannot think of for the moment.

file * | grep 'whatever' | cut -f1 -d':' | xargs -n 1 -i head -n 3 "{}"

Now it handles files with spaces in their name. :-)

[Sorry, had to share that, since it was bothering me while i was washing
up the dishes just now. Now back to your regularly scheduled mailing
list.]

Malcolm

-- 
The cost of feathers has risen; even down is up!


More information about the Techtalk mailing list