LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to output a string by using wildcards? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-output-a-string-by-using-wildcards-790600/)

fish-master 02-21-2010 02:15 PM

How to output a string by using wildcards?
 
I'm trying to make a shell script, and for part of it I need to search through a file, find the ip in the file, and save ONLY the ip to another file. ( not the entire line that its on )
I understand grep has wildcards, where I could do something like,
"grep (...........) traceroute-output
for an ip address.

Any ideas? Thanks.

micxz 02-21-2010 02:58 PM

grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'

does this help'

Tinkster 02-21-2010 02:59 PM

man grep
/-o


Cheers,
Tink

fish-master 02-21-2010 03:03 PM

great. Thanks for the quick help.


All times are GMT -5. The time now is 06:10 PM.