From: Lao Ming on 30 Jan 2010 18:20 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 30 Jan 2010 18:23 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 30 Jan 2010 20:21 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 31 Jan 2010 12:40 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 ...
|
Pages: 1 Prev: a=X; source <( echo a=Y ); echo $a Next: xen, bash, and random seed failure |