regex question

I'm having trouble getting this to work.  What would the regex look like to get just the capital ADV our of this line:

 /dev/vx/dsk/advdg/lvadvsapdata16       /dev/vx/rdsk/advdg/lvadvsapdata16       /oracle/ADV/sapdata16   vxfs    -       yes     -
LVL 1
David AldridgeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David AldridgeAuthor Commented:
That's all one long line.
0
Terry WoodsIT GuruCommented:
Which parts of the line will stay the same, and which will change?
0
David AldridgeAuthor Commented:
if they match "/oracle/\S{3}/\S+\s+ I want to get those three.  The ones that don't match that format, I don't even want to check.
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

ozoCommented:
perl -le 'print "/dev/vx/dsk/advdg/lvadvsapdata16       /dev/vx/rdsk/advdg/lvadvsapdata16       /oracle/ADV/sapdata16   vxfs    -       yes     - " =~ m{/oracle/(\S{3})/\S+\s}'
0
David AldridgeAuthor Commented:
Nope, that one pulls the entire line and puts it in @vfstab.  As a matter of fact, it even puts lines in there that don't have a match to the regex at all.  It just reads all of the /etc/vfstab.  Here's all of my code:

#!/usr/bin/perl

use warnings;

open ( FH, "/etc/vfstab" );
@allvfstab = <FH>;
close FH;

foreach ( @allvfstab ) {
        if ( m{/oracle/(\S{3})/\S+\s} ) {
                push @vfstab, "\n$1";
        }
}

# Get rid of the dupes
foreach $var ( @allvfstab ) {
        if ( !grep( m{$var}, @vfstab ) ) {
                push ( @vfstab, "$var" );
        }
}

print "@vfstab\n";
0
ozoCommented:
# it looks like it is the "Get rid of the dupes" loop that  just reads all of the /etc/vfstab

#!/usr/bin/perl
use warnings;
open ( FH, "/etc/vfstab" ) or die $!;
@vfstab = map{m{/oracle/(\S{3})/\S+\s}} <FH>;
close FH;
print "$_\n" for @vfstab;
0
ozoCommented:
# if you want only unique values

#!/usr/bin/perl
use warnings;
open ( FH, "/etc/vfstab" ) or die $!;
@vfstab{map{m{/oracle/(\S{3})/\S+\s}} <FH>}=();
close FH;
print "$_\n" for keys %vfstab;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David AldridgeAuthor Commented:
ozo, you are absolutely freaking brilliant.  Sorry it took so long to get back but I got sick then had a funeral to go to.  Excellent solution! This one will go in my knowledge base for sure.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.