[Techtalk] re: Joining commands together in bash

Berenice showercurtain2000 at yahoo.com
Tue May 13 00:14:14 EST 2003

The information people have posted has been really helpful! 

On Mon, 12 May 2003, Malcolm wrote:

> The backticks are what are biting you here: The shell executes the
> thing inside the backticks (so you get "hi") and then attempts to 
> run whataver is on the command line after that substitution. That 
> is, it is trying to run the command "hi", which does not exist.

Ok, so that's why 'echo hi' produces an error message! I was starting
to wonder if bash was playing up again. Earlier this year, the head
command was extracting lines from the middle of files, rather than
starting from the top.  Apparently it was caused by some obscure
conflict affecting locale environment variables after updating RPMs
for RH 8. The problem was fixed, but I thought it might have occurred
again because I did an update last week. I'm glad to hear that's not
the case.   

On Mon, 12 May 2003, Random832 wrote:
> the [ x.... != x ] construct has never made much sense to me, when
> simply [ -n ...] works fine

So [ -n...] is equivalent to [ x..!=x ] ?  I couldn't find -n in man

> however, it's much simpler to just check the return status of grep:
> for FILE in *; do
>   if file $FILE | (grep 'shell script text executable'
> &/dev/null);
>  then
>    echo "-- $FILE --"
>    head -n 3 $FILE
>   fi
> done

Could you explain how "&/dev/null" works?  In this case, ampersand
means background execution, right?  

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

More information about the Techtalk mailing list