Copy one column over another in a delimited file
- by user275455
For instance, I needed to remove column 25 and replace it with a copy of column 22 in a simple csv file with no embedded delimiters. The best I could come up with was the awkward looking:
awk -F, '{ for(x=1;x<25;x++){printf("%s,", $x)};printf("%s,",$22);for(x=26;x<59;x++){printf
("%s,", $x)};print $59}'
I would expect something like
cut -d, -f1-24,23,26-59
to work but cut doesn't seem to want to print the same column two times...
Is there a more elegant way to do it using anything typicaly available in a linux shell environment?