Re: shell equivalent to Perl $& op?
From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 04/17/04
- Next message: Steven Ding: "What's the use of "yes"?"
- Previous message: Adam Price: "Re: Disaster Recovery Script using dump"
- In reply to: Gerald Jones: "shell equivalent to Perl $& op?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Apr 2004 22:11:05 -0700
Gerald Jones wrote in message news:
>
> I am trying to extract all IP addresses from a file. I have access to the
> shell, grep, awk and sed but not perl -- which is how I'd normally do it, like:
>
>
> $ perl -ne '/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ && echo "$&\n"'
>
> sooooooooooooooooooo.... anyone know how to do it with sed/awk/grep/something
> else in the standard unix toolchest ...?
>
sed -e '
/\<[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\>/s//\
&\
/;s/.*\n\(.*\)\n.*/\1/p;d
' yourfile
- Next message: Steven Ding: "What's the use of "yes"?"
- Previous message: Adam Price: "Re: Disaster Recovery Script using dump"
- In reply to: Gerald Jones: "shell equivalent to Perl $& op?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|