#DFIR tip: When dealing with CSV files, you can usually avoid Excel & custom scripts when just filtering for particular columns: $ echo "a,b,c,d,e" | cut -d , -f 1,2 a,b $ echo "a,b,c,d,e" | cut -d , -f 1-3,5 a,b,c,e $ echo "a,b,c,d,e" | cut -d , -f 3- c,d,e
16
28
2
117
That's elegant and terse. Thanks! Awk not quite so terse but can do more imho. :-) echo "a,b,c,d,e" | awk -F, '{print $1 "," $2}' echo "a,b,c,d,e" | awk -F, '{print $1 "," $2 "," $3 "," $5}' echo "a,b,c,d,e" | awk -F, '{ {for(i=3; i<=(NF-1); i++) {printf("%s,",$i)}} print $NF}'
2
1
Replying to @mpb @attrc
awk is particularly useful in this context for selecting on columns: awk -F, '$3 == "192.168.1.1"' input.csv awk -F, '$3 ~ /^192.168./' input.csv

Mar 30, 2021 Β· 4:57 PM UTC

1
1
8
Replying to @hal_pomeranz @mpb
I need to learn awk properly. If I can’t figure it out with cut / sed / tr / sort and similar, then I end up writing a quick Python script
2
5