LinuxQuestions.org
Help answer threads with 0 replies.
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 11-27-2005, 11:46 PM   #1
slack66
Member
 
Registered: Jul 2003
Location: manila
Distribution: slackware 8 to 9
Posts: 199

Rep: Reputation: 30
formating text thru awk


hi!
i have a text file that look like this inside:


192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4

i want to extract the file using awk that the output look like this

192.168.0.1

invididually(by row)
 
Old 11-27-2005, 11:58 PM   #2
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
I don't understand: what are you trying to achieve?
By which criteria do you want to extract the individual
IP addresses, and what do you intend to do with the
output? All addresses just separated by an extra new-
line? Or what? :}


Cheers,
Tink
 
Old 11-28-2005, 02:10 AM   #3
slack66
Member
 
Registered: Jul 2003
Location: manila
Distribution: slackware 8 to 9
Posts: 199

Original Poster
Rep: Reputation: 30
ok... iam building a script and i want all my server ip address in one file and i want to extract it in row one by one.
i try ......

awk '{ print $1 ;}' myfileipaddress

the result......

192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.3 etc...

i want the result to this

192.168.0.1 only or

192.168.0.3

iwant it by row not by column
 
Old 11-28-2005, 03:16 AM   #4
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
Code:
sed -e "s/ /\\n/g" myfileipaddress
That'll do it It's not awk but it's close.
 
Old 11-28-2005, 11:20 AM   #5
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
awk 'BEGIN{RS=" "}{print}' file


Cheers,
Tink
 
  


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
Extracting text with grep or awk? UrbanDruid Linux - Newbie 5 04-07-2005 02:57 PM
Formating a file with awk tifu Programming 5 03-16-2005 11:35 PM
awk text that is on several lines homey Programming 2 10-31-2004 09:27 AM
Different editors -- messing up text formating bretzeltux Programming 4 02-16-2004 02:59 PM
command line text formating anyone? DavidPhillips Linux - General 2 11-25-2001 06:26 PM

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

All times are GMT -5. The time now is 09:09 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration