[Techtalk] re: Joining commands together in bash

Berenice showercurtain2000 at yahoo.com
Mon May 12 03:25:23 EST 2003

This is great.  So now I've learned 2 new things about bash.

On Sun, May 11, 2003 at 12:34:07PM +0100, Meredydd wrote:
> This is how I would do it:
> for FILE in * ; do
>   if [ x`file $FILE | grep 'shell script text executable'` != x ]; 
> then
>    head -n 3 $FILE
>   fi
> done

Do newer versions of bash accept statements in the form of
x`blahblah` != x  ?  I know you've said it works in older shells, but
it doesn't seem to work in mine. I don't know if I'm typing it wrong,
but I also tried `echo hi` at the command prompt and got the message
"bash: hi: command not found".  Just wondering...

Date: Sun, 11 May 2003 21:46:52 +1000
From: Malcolm Tredinnick <malcolm at commsecure.com.au>

>Straight out of the "more than one way to skin a cat" bucket, here
>my solution:

>file * | grep 'shell script text executable' | cut -f1 -d':' | xargs

>head -n 3

This is the first time I've seen the xargs command. It's quite handy!


Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

More information about the Techtalk mailing list