Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Neded.

Status
Not open for further replies.

johnny12354

Technical User
Apr 27, 2007
1
GB
Hello Guys, I have no perl experience whatsoever, but am trying to do the following. I have to do the following :

I have a .txt file full of things like

blah logged out from [ xxx.xxx.xxx.xxx ]
blah logged in from [ xxx.xxx.xxx.xxx ]

i need to make a script that will retrieve the contents of the [ xxx.xxx.xxx.xxx ]

and store them into a .txt file is this possible in perl?

Any help would be greatly appreciated.
 
Hi

If your command interpreter does not accept single quotes ( ' ) as parameter delimiter, better put the code in a file :
Code:
s/.*\[ *([[:digit:].]+) *\].*/$1/
and run it as
Code:
perl -p johnny12354.pl /input/file > /output/file

Feherke.
 
or try double-quotes:

Code:
perl -pe "s/.*\[ *([\d.]+) *\].*/$1/" /input/file > /output/file

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top