get only first line using sed / awk
Hi I have a file which contains IP address like this
192.168.28 192.168.28 192.168.28 192.168.28 192.168.28 192.168.28 192.168.28 0.0.0.0 0.0.0.0 0.0.0.0 192.168.8. 0.0.0.0 192.168.8. 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 192.168.28 192.168.28 192.168.28 192.168.28 192.168.28 0.0.0.0 192.168.28 192.168.28 192.168.28 192.168.28 192.168.28 192.168.28 0.0.0.0 I want to get only first IP address. I know they are all same but I need only one ( in the bold) using sed/awk or any other comamnd.. Any help would be great. Thanks. Sam |
have you tried sort -u or uniq?
|
To retrieve the first line of a file there are plenty of methods:
Code:
$ head -n1 file |
There's no need for an external program either.
Code:
read var <infile ; echo "$var" |
All times are GMT -5. The time now is 05:29 AM. |