[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to grep error messages



Hi,

how about:


cd "$1"

if [ $? != '0' ]; then
  echo "damn."
  exit;
fi


greetings,
vitaminx


2009/6/28 Soren Orel <soren.orel@gmail.com>
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

thank you!



--
www ... http://www.callistix.net/
mail ... vitaminx@callistix.net
irc ... #chezpaeule @ euirc
mud ... vitaminx @ aardmud

Reply to: