![]() |
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 |
| Can IBM Simplify Complex Event Processing? | iBot | Complex Event Processing RSS News | 0 | 04-09-2008 08:10 PM |
| Shell Script: want to insert values in database when update script runs | ring | Shell Programming and Scripting | 1 | 10-25-2007 03:06 AM |
| a script to simplify the use of grep | kemobyte | Shell Programming and Scripting | 2 | 05-01-2007 01:57 PM |
| Howto Simplify Multiple Exports in .bash_profile | monkfan | Shell Programming and Scripting | 1 | 03-30-2006 07:49 AM |
| Howto Simplify/Factorize Exports in .bash_profile | monkfan | UNIX for Dummies Questions & Answers | 1 | 03-29-2006 11:59 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can I simplify the script
Hi all,
How can I simplify following script, Logic is to find two strings (strings are case sensitive) from a file. if [ `grep -x "$1" "$path"/Hostname/$file_name|wc -l` -eq 1 ]; then if [`grep -x "$2" "$path"/Hostname/$file_name|wc -l` -eq 1 ]; then Group=`echo $1_hostname` fi fi Please help me on this. Regards Sudhish s. kumar |
|
||||
|
You can do something like
Code:
grep -x "$1" "$path"/Hostname/$file_name >/dev/null 2>&1
rtn1_val=$?
grep -x "$2" "$path"/Hostname/$file_name >/dev/null 2>&1
rtn2_val=$?
if [[ $rtn1_val -eq 0 && $rtn2_val -eq 0 ]]
then
Group=`echo $1_hostname`
fi
|
|
||||
|
grep -e "(string1|string2)" /filename
This command is not working In fact I was looking for some thing like you suggested Thanks Regards Sudhish S. Kumar |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|