Setting delimiter to the equal sign or tab.
awk '-F "=" {print $1}' input.txt awk '-F $"\t" {print $1}' input.txt
If-Else
awk 'if (cond) {} else {}' input.txt
Two ways to print the rest fields but not some specified one (Watch out use double quotes for the second solution)
awk 'for (i = 2; i <= NF; i++) printf $i " "' awk '$1=""; print'
Running awk file
#File: fs_regex.awk #!/bin/awk BEGIN { FS = "[| \t]+" } {for(i=1; i<=NF; i++) print $i}
awk -f fs_regex.awk input.txtA typical row of database query from command line:
| 27 | IN | 17042014163416 | 21 | 0633040997 | 0633040998 | 000 | 500 | 2014/04/17 | 16:34:16 | BE7699730381555507734 | test.tif | TIFF | 0633040997 | 0 | 0633040998 | 20 | 11062 | 200 | 600 | 17 04 2014 | 16:34:16 | BE7699730381555507734 | test.tif | TIFF | 0633040997 | 0 | 0633040998 | 20 | 0 |Result
27 IN 17042014163416 21 0633040997 0633040998 000 500 2014/04/17 16:34:16 BE7699730381555507734 test.tif TIFF 0633040997 0 0633040998 20 11062 200 600 17 04 2014 16:34:16 BE7699730381555507734 test.tif TIFF 0633040997 0 0633040998 20 0
No comments:
Post a Comment