This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 请问: how to swap columns 1 and 2 in a text file?
-dou(xiaoli);
2003-9-17
(#1372942@0)
-
什么平台,什么分隔符号?
-oceandeep(北极熊·猪真的很快乐);
2003-9-17
(#1372964@0)
-
solaris上, 用空格分隔, 谢谢.
-dou(xiaoli);
2003-9-17
(#1372993@0)
-
here you arecut -f1 -d' ' sourcefile > tmpfile1
cut -f2 -d' ' sourcefile > tmpfile2
cut -f3-x -d' ' sourcefile > tmpfile3
paste tmpfile2 tmpfile1 tmpfile3 > tmpfile4
sed 's/\t/ /g' < tmpfile4 > resultfile
FYI: the x in the 3rd command should be the total column# of that file.
-oceandeep(北极熊·猪真的很快乐);
2003-9-17
{280}
(#1373056@0)
-
哦,忘记了rolia不支持这个符号\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\,最后一句显示错误了,反正最后你把tmpfile4,里面的tab分隔符号,变成空格就ok了
-oceandeep(北极熊·猪真的很快乐);
2003-9-17
(#1373099@0)
-
awk '{ printf "%s %s", $2, $1; for (i=3; (i <=NF); i+=1) {printf " %s", $i} print "" }' filename > new_filename
-show_me_the_money(见钱眼开);
2003-9-17
(#1373174@0)
-
awk '{print $2,$1}'
-ztech(Techno Zoom);
2003-9-17
(#1373182@0)