Hi folks,
I got some trouble using awk under special circumstances.
I'm trying to fetch specific fields of a list.
Something like that:
So far no problem. If I want to get field 1 and 4 I simply use
Where the output would look like this:
Perfect! However in this specific case the file file.txt might look something like this:
See my problem ?
Using the above awk statement I get the following output:
Any idea how I could solve this issue ?
Regards,
Thomas
I got some trouble using awk under special circumstances.
I'm trying to fetch specific fields of a list.
Something like that:
Code:
> cat file.txt
0001 GE1 20100921 0x01 T1
0002 GE2 20100920 0x01 T2
0003 GE3 20090817 0x02 T3
So far no problem. If I want to get field 1 and 4 I simply use
Code:
cat file.txt | awk '{print $1 $4}' FS=' '
Where the output would look like this:
Code:
0001 0x01
0002 0x01
0003 0x02
Perfect! However in this specific case the file file.txt might look something like this:
Code:
> cat file.txt
0001 GE1 20100921 0x01 T1
0002 GE2 0x01 T2
0003 GE3 20090817 0x02 T3
See my problem ?
Using the above awk statement I get the following output:
Code:
0001 0x01
0002 T2
0003 0x02
Any idea how I could solve this issue ?
Regards,
Thomas