例如,我需要刪除第25列,並將其替換爲第22列的副本,但不包含嵌入的分隔符。我能想出的最好的是尷尬的看着: 在分隔文件中將一列複製到另一列
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?
這是一種可悲的是切不支持,那肯定是一個非常有用的功能。 – 2010-04-20 16:19:23
'cut'不重新排列列,或者:'echo -e「a \ tb \ tc」| cut -f 3,2,1'結果爲「a [tab] b [tab] c」 – 2010-04-20 17:07:56