Awk help
Hi All,
I have a file "host" with three columns in it like below and i tried below double FOR loop to print 1 column in one iteration. i use two/three ways but all fails with no error/output. please let me know where i am wrong. please suggest if there is any other way to do this. file with 3 columns a b c a b c a b c a b c a b c . . . method 1 for i in 1 2 3 do for HOSTS in `awk -v var=$i '{print var}' host|grep -i VHL..WX|sed 's/^#//'` do echo $HOSTS ............ ............ ............ done done method 2 for i in 1 2 3 do for HOSTS in `awk '{print var}' var=$i host|grep -i VHL..WX|sed 's/^#//'` do echo $HOSTS ............ ............. ............... done done |
If file t.t contains data as above, then
Code:
awk '{print $1}' t.t |
Probably 'cut' command can also be used:
$ cut -d" " -f1 file.txt Only first column should be printed out. |
Possibly, but cut requires exactly 1 char (in this case space) as the delimiter; awk uses any amt of contiguous whitespace, so a bit more flexible.
Without code tags we can't be sure of the data spacing ;) |
All times are GMT -5. The time now is 01:12 AM. |