![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to negate grep result? | mmdawg | Shell Programming and Scripting | 4 | 05-05-2008 08:24 AM |
| append a string to a grep result | melanie_pfefer | Shell Programming and Scripting | 8 | 03-19-2008 07:19 AM |
| grep to handle a 0 result | ocelot | UNIX for Dummies Questions & Answers | 6 | 02-05-2007 11:19 AM |
| To have a numeric result from grep | Hak Dee | UNIX for Dummies Questions & Answers | 2 | 08-07-2006 07:26 AM |
| is there any why to get the number of line in grep result ? | umen | UNIX for Dummies Questions & Answers | 1 | 03-16-2006 09:56 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
diaplaying the grep result
Hi,
My code is like this Code:
if swlist -a revision 2>/dev/null | grep ABC 2>/dev/null
then
echo "Found Above mentioned ABC Version, please remove it first..."
fi
i want to first suppress that and for that i wrote the below code Code:
if swlist -a revision 2>/dev/null | grep ABC 2>/dev/null > /dev/null
then
$temp=swlist -a revision 2>/dev/null | grep ABC 2>/dev/null
echo "Found $temp ABC Version, please remove it first..."
fi
But it is not working .... can any one help me??? Thanks |
|
||||
|
The syntax of the assignment is all wrong. But you can avoid running the thing twice. This is one of the few situations where really you want to execute a command first, and then examine its exit code in $?
Code:
temp=`swlist -a revision 2>/dev/null | grep ABC` # note backticks, not regular quotes
case $? in 0) # grep succeeded, meaning it was found
echo Found $temp ABC version, please remove it first ... >&2 ;;
esac
Last edited by era; 03-27-2008 at 02:39 AM.. Reason: Had inverted the success condition, oops |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|