Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trying to pull a substring out of a string.

819570Jan 26 2011 — edited Jan 26 2011
Hi,
We're using GNU/Linux version 2.6.18.194.26.1.0.1.el15 X86_64.

What is the simplest way to pull a sub string out of the following string

REV00006.REV.BCBSIL_TCH_20110125.pgp

We specifically want the date portion '20110125'.

Is there a way to do that at the command line.

I'm pulling records from a file and have gotten this far
cat testlist |grep REV | awk '{print $9}'|grep '[R]'
where 'testlist' list contains several lines, two of which we need that get returned by the above command. The out put is the following:
REV00006.REV.BCBSIL_TCH_20110125.pgp
REV00006.REV.BCBSIL_TCH_20110224.pgp
The goal is to pull the latest file name which would be 'REV00006.REV.BCBSIL_TCH_20110224.pgp'

That's the line we need. What's the best way to do this?
I'm not a shell scripting guru.

My thought is we'd pull the sub-string dates out of each string, compare them and then store or output the latest file name.

So I'd use the above command to feed the output into what ever shell script you'd suggest I write or if possible feed it into another awk command.

Please help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2011
Added on Jan 26 2011
4 comments
198 views