![]() |
|
|
|
|
|||||||
| 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 |
| Help me for AWK URGENT | readycpbala | Shell Programming and Scripting | 2 | 02-22-2007 10:03 AM |
| URGENT,URGENT- Need help tape drive installation | sriny | UNIX for Advanced & Expert Users | 3 | 11-16-2006 12:43 PM |
| URGENT---URGENT--No OK PROMPt after RSC CONFIG | sriny | SUN Solaris | 7 | 10-29-2006 08:06 AM |
| Urgent !! | desiondarun | UNIX for Dummies Questions & Answers | 1 | 08-08-2006 05:49 AM |
| urgent 2 | hamoudzz | UNIX for Dummies Questions & Answers | 1 | 03-03-2004 06:09 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi Guys,
Need one quick help. I have one file test.sh #cat test.sh <Abc>200712241314</Abc> I need the output value in between <Abc> </Abc> mean to say "200712241314" I am using cut command for that. But my problem is that test.sh file not same format. Some time it will have some whitespace from start. Could you help me. I want the ouput value in between <Abc> </Abc> in anywhere that file. It is Urgent !! Thanks Sanjay |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
man sed - urgently!!
I guess that you do not have multiple <Abc>..</Abc>-combinations on one line so that following line would be impossible: Code:
blabla <Abc> value1 </Abc> blabla <Abc> value2 </Abc> blabla Code:
sed 's/^.*<Abc> *\([^<spc><tab>][^<spc><tab>]*\) *<\/Abc>.*$/\1/' test.sh bakunin |
|
#3
|
||||
|
||||
|
using Perl:
Code:
#!/usr/bin/perl
# extract_num.pl
while (<>) {
print $1 if (m#^\s*<Abc>(\d+)</Abc>#);
}
Code:
perl extract_num.pl test.sh |
|
#4
|
|||
|
|||
|
Quote:
([^<spc><tab>][^<spc><tab>]*\) & ".*$/\1" . Thanks Bishweshwar |
|
#5
|
|||
|
|||
|
Try This Out!!!!!!!!!!!!!!!!!!!!!!!!!
sed 's/\(<Abc>\)\(.*\)\(<\/Abc>\)/\2/' filename Regards, Anand |
|||
| Google The UNIX and Linux Forums |