mercoledì 29 febbraio 2012

Substring variable length record with awk.

The daily problem is this : I must print from third field to end of all records in a file where fields are separated from Tab character.

To resolve this problem i use awk in this way :

cat | awk -F" " '{ printf "%s\n",substr($0,index($0,$3)) }'

Where in -F awk option I specify tab character, and I use substr with index function of third field in each record read.

Stay tuned.





Nessun commento:

Posta un commento

Check first quarter 2024

 Hi all Today, 1st May I'll check my 2024 goals. This is the first time I check it. For me it's a good way to reach more objective p...