Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-21-2010, 02:15 PM   #1
LQ Newbie
Registered: May 2007
Posts: 4

Rep: Reputation: 0
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.
Old 02-21-2010, 02:58 PM   #2
Senior Member
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'

does this help'
Old 02-21-2010, 02:59 PM   #3
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
man grep

Old 02-21-2010, 03:03 PM   #4
LQ Newbie
Registered: May 2007
Posts: 4

Original Poster
Rep: Reputation: 0
great. Thanks for the quick help.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problems getting a segement from a string output tzvio Programming 1 10-22-2009 02:57 PM
How to search for a string in a text file using wildcards(*,?) tnjones Programming 2 08-23-2008 07:04 AM
output the path for files whose names include string "string" (case insensitive) sean_zhang Linux - Newbie 1 03-04-2008 11:59 PM
How to compare the output of a command with a string? daYz Programming 2 12-31-2006 09:36 AM
parsing a string from grep output in bash xpromisex Programming 2 11-12-2006 09:12 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration