![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| file Lookup using awk | jerome Sukumar | Shell Programming and Scripting | 1 | 08-30-2007 12:28 AM |
| Lookup with a file | pavan_test | UNIX for Dummies Questions & Answers | 5 | 07-21-2006 07:57 AM |
| reverse lookup file problem | Westy564 | IP Networking | 2 | 01-09-2004 11:55 AM |
| file lookup | gillbates | UNIX for Dummies Questions & Answers | 6 | 12-12-2003 11:04 AM |
| grep multiple text files in folder into 1 text file? | coppertone | UNIX for Dummies Questions & Answers | 7 | 08-23-2002 11:50 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
Hi ripat
u almost read my mind. removing those things will be helpful but not necessary for me. My final objective, which i didnt mention, was to search for pattern 'condition' after retrieving the text and then output the job name which is there after 'condition'. I tried running the code u gave and this is what its giving while read str > do > sed -n "/-- $str --/, /^$/ {/-- $str --/b;/^$/b;p}" b1 > done<a1 sed: command garbled: /-- ab --/, /^$/ {/-- ab --/b;/^$/b;p} sed: command garbled: /-- cd --/, /^$/ {/-- cd --/b;/^$/b;p} sed: command garbled: /-- ef --/, /^$/ {/-- ef --/b;/^$/b;p} can u explain the command line in a bit of detail...for e.g. what is the b obtion for :- {/-- $str --/b;/^$/b;p} is it for replacing with a blank? I also ran the awk script. That is not returning anything..just the command prompt. while read str do awk 'BEGIN{FS="\n"; RS="\n\n"; OFS="\n"} /-- ab --/ {for (i = 2; i <= NF; i++) print $i}' b1 done<a1 |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
Quote:
Here trying to match from a line with pattern /\/\*--* $str --*\*\// to another line with the pattern /^ *$/.If you want to specify two address then you have to separate it with comma. /^ *$/ * matches any number or none of the single character that immediately precedes it.So this will match empty line as well as lines with blanks. |
|
#10
|
|||
|
|||
|
Quote:
this funda i hadnt come across in the 2 months that i hv been learning unix. i thought only sed '1,3 p' works. didnt know patterns can also be matched the same way. |
|
#11
|
|||
|
|||
|
Quote:
You can use d to achieve the same result Code:
while read str
do
sed -n "/-- $str --/, /^$/ {/-- $str --/d;/^$/d;p}" b1
done<a1
|
|||
| Google The UNIX and Linux Forums |