awk combined with an IF

Hi everybody!

I try to printout a csv-file with the exeption of cell $1 and $4.
what i tried so far:

awk '{for(i = 1; i<=NF; i++);if(i == 1 || i == 4);else print($i)}' file.csv

..any ideas how it work and why my example fails?

Thanks in advance!
IMPe

awk '{for(i = 1; i<=NF; i++);if(i != 1 && i != 4) print($i)}' file.csv
1 Like

Maybe?

awk '{$1=$4=":"; gsub(/:,/, "")};1' OFS=, FS=, file.csv
1 Like

YES, that works fine.
Thanks a lot!
IMPe