Need Help Urgent

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

man sed - urgently!!

I guess that you do not have multiple <Abc>..</Abc>-combinations on one line so that following line would be impossible:

 blabla  <Abc> value1 </Abc> blabla <Abc>    value2   </Abc> blabla

If this *is* the case you should start reading the sed-manpage even more urgently, as it is going to be a little more elaborate than the simple case replace "<spc>" "<tab>" by literal blanks and tabs:

sed 's/^.*<Abc> *\([^<spc><tab>][^<spc><tab>]*\) *<\/Abc>.*$/\1/' test.sh

This removes the whitespace too.

bakunin

using Perl:

#!/usr/bin/perl
# extract_num.pl
while (<>) {
    print $1 if (m#^\s*<Abc>(\d+)</Abc>#);
}

Then run this script as:

perl extract_num.pl test.sh

Can you explain how this part works.......
([^<spc><tab>][^<spc><tab>]\) & ".$/\1" .

Thanks
Bishweshwar

Try This Out!!!!!!!!!!!!!!!!!!!!!!!!!

sed 's/\(<Abc>\)\(.*\)\(<\/Abc>\)/\2/' filename

Regards,
Anand