本帖最后由 tommytangtang 于 2014-9-3 09:39 编辑
文本Text1.txt如下:
23,123,345,234,345,345,456,123
24,345,234,345,345,456,123,123
25,123,345,234,345,345,456,123
打印出来后新文本Text1A.txt如下:
123,123,345,234,345,345,456,123
124,345,234,345,345,456,123,123
125,123,345,234,345,345,456,123
文本里面的数据是没有规律的,每行列数也不一定,所以一定要用到NF
只是第一列统一加100,后面不变
@gawk -F"," "FNR==1{sub(/\.[^\.]*$/,\"A^&\",FILENAME)}{for (i=1;i<=NF;i++)print $1+100,$i>FILENAME}" *.txt
这样打出来都变成2列了,求大神指点 |