![]() |
|
|
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 |
| awk as grep with variables | pp56825 | Shell Programming and Scripting | 7 | 02-15-2008 09:34 AM |
| combined stdout & stderr | slavam | UNIX for Advanced & Expert Users | 11 | 10-12-2007 04:06 PM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-05-2007 03:59 AM |
| FIND/CHMOD combined | smoother | Shell Programming and Scripting | 33 | 09-22-2007 06:59 AM |
| Using grep with variables | gettingstarted | Shell Programming and Scripting | 2 | 02-04-2005 10:52 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grep command with combined variables in Ksh
Hi,
I'd like to grep two variables that are seperated with one space in ksh. var1="Feb" var2="09" I tried to grep "$var1 ""$var2" /usr/file It turn into grep Feb 09 /usr/file when it runs. I got error. Can some one help me with this one? Thanks a lot for your help! |
|
||||
|
Or if you want to find both strings even when they are not right next to each other, pipe your greps together, like this:
grep Feb /usr/file | grep 09 This would find it even if the exact text isn't Feb 09 but both pieces are on the same line. For example, it would find "Today is Feb 09" but it would also find "My grandfather was born in February 1909". The method blowtorch suggested is better if you want to find just the exact string Feb 09. Ok, I just noticed the line where you said they need to be separated by one space, so I guess blowtorch's method is better. But I might as well leave this here for more information since I bothered to type it in. :-) |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|