Example csv:
AAA, BBB, CCC, DDD, EEE, FFF, GGG, HHH
Now i wan't a copy column 2 (BBB) and add it in front of column 3 so the file looks like:
AAA, BBB, BBB, CCC, DDD, EEE, FFF, GGG, HHH
$ cat test.txt
AAA, BBB, CCC, DDD, EEE, FFF, GGG, HHH
AAA, BBB, CCC, DDD, EEE, FFF, GGG, HHH
AAA, BBB, CCC, DDD, EEE, FFF, GGG, HHH
$ awk -F, '{$2=$2","$2}1' OFS=, test.txt
AAA, BBB, BBB, CCC, DDD, EEE, FFF, GGG, HHH
AAA, BBB, BBB, CCC, DDD, EEE, FFF, GGG, HHH
AAA, BBB, BBB, CCC, DDD, EEE, FFF, GGG, HHH
awk '{print $1,$2,$2,$3,$4,$5,$6,$7,$8}' file.csv
➤ echo "AAA, BBB, CCC, DDD, EEE, FFF, GGG, HHH" | awk '{print $1,$2,$2,$3,$4,$5,$6,$7,$8}'
AAA, BBB, BBB, CCC, DDD, EEE, FFF, GGG, HHH