#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
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
1
1
8
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
4
Replying to @attrc @mpb
Maybe this will help a little blog.commandlinekungfu.com/2…

Mar 30, 2021 Β· 5:27 PM UTC

6