LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   formating text thru awk (https://www.linuxquestions.org/questions/linux-newbie-8/formating-text-thru-awk-387160/)

slack66 11-27-2005 11:46 PM

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)

Tinkster 11-27-2005 11:58 PM

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

slack66 11-28-2005 02:10 AM

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 :)

cs-cam 11-28-2005 03:16 AM

Code:

sed -e "s/ /\\n/g" myfileipaddress
That'll do it :) It's not awk but it's close.

Tinkster 11-28-2005 11:20 AM

awk 'BEGIN{RS=" "}{print}' file


Cheers,
Tink


All times are GMT -5. The time now is 07:35 AM.