From: Lao Ming on
In the following command:

if echo "${DIR##*/}" |egrep "^($EXCLUDE)" ; then

I'd like to prevent the echo output to the pipe from going to stdout
in my script. Is this possible?

The entire code (so far) is:

EXCLUDE="bin|log|errors"
find . -type d |sed 's/ /\\ /g' |
{
while IFS="
" read -r DIR ; do
if echo "${DIR##*/}" |egrep "^($EXCLUDE)" ; then
continue
fi
echo "$DIR"
done
}

Thanks for any help.
From: Seebs on
On 2010-01-30, Lao Ming <laomingliu(a)gmail.com> wrote:
> In the following command:
>
> if echo "${DIR##*/}" |egrep "^($EXCLUDE)" ; then
>
> I'd like to prevent the echo output to the pipe from going to stdout
> in my script. Is this possible?

Probably. It sounds like you want either grep -q or grep >/dev/null.

That said, typically this is spelled:
case ${DIR##*/} in
$EXCLUDE*) continue;;
esac

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Evergreen on
On comp.unix.shell, Lao Ming <laomingliu(a)gmail.com> wrote:
> In the following command:
>
> if echo "${DIR##*/}" |egrep "^($EXCLUDE)" ; then
>
> I'd like to prevent the echo output to the pipe from going to stdout
> in my script. Is this possible?
>
> The entire code (so far) is:
>
> EXCLUDE="bin|log|errors"
> find . -type d |sed 's/ /\\ /g' |
> {
> while IFS="
> " read -r DIR ; do
> if echo "${DIR##*/}" |egrep "^($EXCLUDE)" ; then
> continue
> fi
> echo "$DIR"
> done
> }
>
> Thanks for any help.

Assuming bash:

if .... &> /dev/null

then ....

Sid
From: mop2 on
On Sat, 30 Jan 2010 21:20:15 -0200, Lao Ming <laomingliu(a)gmail.com> wrote:

> In the following command:
>
> if echo "${DIR##*/}" |egrep "^($EXCLUDE)" ; then
>
> I'd like to prevent the echo output to the pipe from going to stdout
> in my script. Is this possible?
>

If your "grep" has "-q" option, then is easy:
grep -q ...