Created
September 17, 2021 14:52
-
-
Save mikybars/2628fa6e09f2343f0895df10811783aa to your computer and use it in GitHub Desktop.
[Print field names along their indexes from tabular data] Most useful for big log files #csv #awk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk '(NR==1) {for (i=1;i<=NF;i++) print i ": " $i}' <data.csv | |
# 1: date | |
# 2: time | |
# 3: x-edge-location | |
# 4: sc-bytes | |
# 5: c-ip | |
# 6: cs-method | |
# 7: cs(Host) | |
# ... | |
# print date, time and ip | |
awk 'NR > 1 { OFS=" | "; print $1,$2,$5 }' <data.csv | |
# 2019-12-04 | 21:02:31 | 192.0.2.100 | |
# 2019-12-04 | 21:02:31 | 192.0.2.100 | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment