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

Re: how to grep error messages



Hi,

On Sun, Jun 28, 2009 at 11:39:55AM +0200, Soren Orel wrote:
> I can /dev/null the error messages like:
> 
> cd "$1" 2> /dev/null

2> will redirect to a file /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

What are you doing.  If you wish to pipe error output of cd "$1", then
do so.  "2>" requires file!.  Also please note "cd" in buildin.

Justbtest for directory using "-d" as others should have mentioned...


Reply to: