LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-21-2010, 03:15 PM   #1
fish-master
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, 03:58 PM   #2
micxz
Senior Member
 
Registered: Oct 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, 03:59 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
man grep
/-o


Cheers,
Tink
 
Old 02-21-2010, 04:03 PM   #4
fish-master
LQ Newbie
 
Registered: May 2007
Posts: 4

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


Reply


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 03:57 PM
How to search for a string in a text file using wildcards(*,?) tnjones Programming 2 08-23-2008 08:04 AM
output the path for files whose names include string "string" (case insensitive) sean_zhang Linux - Newbie 1 03-05-2008 12:59 AM
How to compare the output of a command with a string? daYz Programming 2 12-31-2006 10:36 AM
parsing a string from grep output in bash xpromisex Programming 2 11-12-2006 10:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:32 AM.

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