![]() |
|
|
|
|
|||||||
| 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 |
| awk: need to extract a line before a pattern | npn35 | Shell Programming and Scripting | 17 | 06-29-2008 07:38 PM |
| extract a particular start and end pattern from a line | manish205 | Shell Programming and Scripting | 7 | 02-07-2008 03:18 AM |
| Extract Pattern Sequence | jaganadh | Shell Programming and Scripting | 5 | 12-10-2007 08:06 AM |
| Extract if pattern matches | Raynon | Shell Programming and Scripting | 20 | 10-29-2007 01:44 AM |
| Extract the Pattern | aajan | UNIX for Dummies Questions & Answers | 6 | 08-08-2007 01:47 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Please help! Sed extract a pattern
I am trying to extract "securitySettings" out of line:
<a ref ="http://localhost:5654/securitySettings"> using sed as follows: name = `grep "localhost" file.html | sed -n 's/.*[0-9]*\/\(.*)/\">/\1/p'` But it didn’t run, seems have some syntax error. Do anybody knows why? Thank you very much! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
you missed \ in \(.*\)
unnecessary / in /\">/\1/p after those modifications Code:
sed -n 's/.*[0-9]*\/\(.*\)">/\1/p' Last edited by anbu23; 09-14-2006 at 02:20 PM. |
|
#3
|
|||
|
|||
|
emmmm, why this did not work? it has a ">" at the end of output
$ sed 's/^.*:[0-9][0-9]*\/\([^\"]*\)\"\>/\1/' /tmp/test securitySettings> |
|
#4
|
||||
|
||||
|
Code:
sed -n 's_.*/\([^/]*\)">_\1_p' |
|
#5
|
|||
|
|||
|
can be don in a much more simpler way as follows(i mean there is lesser chance of getting lost in sed
Code:
grep "loaclhost" file.html | awk -F'/' '{print $NF }' | sed -e 's/>//g'
|
|
#6
|
|||
|
|||
|
Quote:
Code:
grep "securitySettings" file.html if [ $? -eq 0 ]; then name='securitySettings' fi |
|
#7
|
|||
|
|||
|
Quote:
|
|||
| Google The UNIX and Linux Forums |