![]() |
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 |
| grep with variable | ozvena | Shell Programming and Scripting | 5 | 05-14-2008 03:05 PM |
| how to pass variable to grep? | xist | Shell Programming and Scripting | 2 | 11-29-2007 07:45 AM |
| setting variable from grep | cut | doublejz | Shell Programming and Scripting | 1 | 08-24-2005 03:39 PM |
| How to grep a variable? | whatisthis | Shell Programming and Scripting | 2 | 09-14-2004 06:26 PM |
| Grep from a file variable | jagannatha | UNIX for Dummies Questions & Answers | 5 | 10-30-2003 05:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
question on sed grep awk from variable
i am still confusing on how to use sed, grep and awk if the input is not a file but a variable.
such as: a="hello world" b="how are you" c="best wish to you" d="222,333,444" what if i want to check which variable $a,$b,$c,$d have contain "you" what if i want to replace the word "you" to "me" what if i want to grep the 2nd field of the varible How should i do ? Does echo $* must be use in all case ? Can someone give me a good example on this ? Many thanks !! |
|
||||
|
# check if variable 'a' contains 'you'
if echo "$a" | grep -q you then echo "Variable a contains 'you'" fi I have the following output ----> egrep: illegal option -- q usage: egrep [ -bchilnsv ] [ -e exp ] [ -f file ] [ strings ] [ file ] ... Also, i have one more question: how to pass the variable out of awk? example of my script but did not work. echo $* | awk -F: '{a=$1 b=$2 c=$3}' #echo $* | awk -F: '{"a=%s b=%s c=%s\n",$1, $2, $3}' <<- not work too. print $a print $b print $c thanks you! |
|
||||
|
thanks you
Quote:
grep: illegal option -- q Usage: grep -hblcnsviw pattern file . . . |
![]() |
| Bookmarks |
| Tags |
| grep or |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|