LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 02: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, 02:58 PM   #2
micxz
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
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


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

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


Reply



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

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

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

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
Open Source Consulting | Domain Registration