[Techtalk] re: Joining commands together in bash
Rasjid Wilcox
rasjidw at openminddev.net
Tue May 13 19:29:08 EST 2003
On Tuesday 13 May 2003 17:14, Berenice wrote:
>
> So [ -n...] is equivalent to [ x..!=x ] ? I couldn't find -n in man
> bash.
Try 'man test' instead. (See Malcom's post.)
> > 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?
I think a > was lost in line wrap-around. The original post had:
... >&/dev/null
which means redirect all output (both output to stdout and stderr) to
/dev/null. The & in this case is not background execution, but says 'join
the output from stdout and stderr together'. The result is that you don't
see any output from the grep command, since it has been redirected to the
null device. See man bash for more details.
Rasjid.
--
Rasjid Wilcox
Canberra, Australia UTC + 10
http://www.openminddev.net
More information about the Techtalk
mailing list