1827802 Members
2330 Online
109969 Solutions
New Discussion

Re: data extraction

 
SOLVED
Go to solution
Pando
Regular Advisor

data extraction

I have a data inside the file

...
...
"P-BC-0504-6041"
...
...

I need to get the 6041 number only.

Can i accomplish this using awk or sed?

Maximum points to all correct reply.



4 REPLIES 4
john korterman
Honored Contributor
Solution

Re: data extraction

Hi,
if the central "P-BC-0504-6041" string is embeded in double quotes, and these are the ones, you could try something very simple:
# awk -F"\"" '{print $2}'
regards,
John K.
it would be nice if you always got a second chance
Peter Godron
Honored Contributor

Re: data extraction

Fernando,

cat data.file | cut -d'"' -f2 | cut -d'-' -f4

Regards
harry d brown jr
Honored Contributor

Re: data extraction

grep ED_ORDERNR FILENAME | sed "s/\(\\"\)\(.*\)\-\(.*\)-\(.*\)-\(.*\)\(\"\<\/ED_ORDERNR\>\)/\5/"

live free or die
harry d brown jr
Live Free or Die
Pando
Regular Advisor

Re: data extraction

Many thanks to all!