Operating System - HP-UX
1833873 Members
1763 Online
110063 Solutions
New Discussion

Re: Easy Perl Question - How to limit to no more that 6 digits

 
SOLVED
Go to solution
Laurie_2
Advisor

Easy Perl Question - How to limit to no more that 6 digits

Hi All,

I'm need a little scripting help.

My perl command:
perl -nle '/ - (\d+)/&&print$1' open0519.log > studentid.0519

Works fine to give me id numbers, however
sometimes it picks up the passwords numbers
which I don't want.

I want to keep my perl command above I just
only want to bring in a max of 6 digits.

It can be less than 6 digits but no more
than 6 digits.

My output looks something like this:

504123
609888
989
1234564444 <-- Bad Data, only want 123456

I just want to truncate anything over
6 digits, keeping my perl command above basically in tack, since it works great
other than this one issue.

TIA,
Laurie


How can you make the world a better place
2 REPLIES 2
Jordan Bean
Honored Contributor

Re: Easy Perl Question - How to limit to no more that 6 digits

perl -nle '/ - (\d{1,6})/&&print$1' open0519.log > studentid.0519
Jordan Bean
Honored Contributor
Solution

Re: Easy Perl Question - How to limit to no more that 6 digits

wiat... that will grab the first six digits of the long stuff... what follows the id? Try this instead:

perl -nle '/ - (\d{1,6})\b/&&print$1' open0519.log > studentid.0519