![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep help | flood | Shell Programming and Scripting | 3 | 06-05-2008 10:14 PM |
| Grep | Aejaz | UNIX for Advanced & Expert Users | 3 | 04-30-2008 04:10 AM |
| grep | dineshr85 | Shell Programming and Scripting | 1 | 10-10-2007 01:52 AM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-04-2007 11:59 PM |
| Make grep -c display like grep -n? | Jerrad | Shell Programming and Scripting | 2 | 08-24-2006 09:20 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
grep and ksh
Hi,
Can someone please help me with the below query, I have a list of country codes in an array 'tempCountry'. I need to search for the occurence of the string "[countryCode]" in a log. eg: "grep '\[DE]\' myLog" works fine. However when i do the following in a ksh script, it doesn't work as intended Code:
tempCountry=${countries[${count}]}
if [[ $(grep -c '\[${tempCountry}\]' ${MY_LOG}) -gt 0 ]] ; then
echo "Found ${tempCountry} in log"
else
echo "Not Found ${tempCountry} in log"
TIA |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
change:
Code:
grep -c '\[${tempCountry}\]'
Code:
grep -c "\[${tempCountry}\]"
You can see this happening by placing "set -x" before if statement and "set +x" after the last line of the if statement. |
|||
| Google The UNIX and Linux Forums |