Am 2009-06-28 11:39:55, schrieb Soren Orel: > I can /dev/null the error messages like: > > cd "$1" 2> /dev/null > > e.g.: I get error If "$1" has spaces in it > > Ok, but how can I grep the error message? I tried: > > if cd "$1" 2> grep -i "No such file or directory"; then echo "badbadbad"; > exit; fi > > But it doesn't work :S
You need to redirect it to STDOUT with: if [ $(cd "$1" 2>&1 |grep -i "No such file or directory" ] then echo "badbadbad" ; exit fi But I would prefer something like: if [ $(cd "$1") -ne 0 ] then echo "badbadbad" ; exit 1 fi Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator 25.9V Electronic Engineer Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ ##################### Debian GNU/Linux Consultant ##################### Michelle Konzack c/o Shared Office KabelBW ICQ #328449886 +49/177/9351947 Blumenstasse 2 MSN LinuxMichi +33/6/61925193 77694 Kehl/Germany IRC #Debian (irc.icq.com)
signature.pgp
Description: Digital signature