2017-05-27 45 views
0

我可以知道如何編寫一個Unix命令來刪除所有行和多個文件中的兩個特定字段(第28和30列)的最後一個字符。刪除前文件1UNIX命令刪除多個文件中的兩個特定字段的最後一個字符

例子:

0,0,1,14289067,10114404,145,60104212839,1,1,1,8801971507671,1,60104212839,1,8801971507671F,4,170523,170523,1,1,235045,235045,0,0,255,1,0,BMRBGBO,0,BWGKPEI,16758,2,6,00000000000,8801971507671,0,0,,FFFFFFFFFFFFFFFFFFFFFFFF,3 
1,14286085,10114405,142,601124225298,1,1,1,1062895388906858,1,601124225298,1,1062895388906858F,41,170523,170523,1,1,235045,235045,0,1,255,1,0,BINDMAO,0,BWGKPAI,39285,2,6,00000000000,62895388906858,0,,FFFFFFFFFFFFFFFFFFFFFFFF,2 

在領域28和30取出的最後一個字符後,在文件1:

0,0,1,14289067,10114404,145,60104212839,1,1,1,8801971507671,1,60104212839,1,8801971507671F,4,170523,170523,1,1,235045,235045,0,0,255,1,0,BMRBGB,0,BWGKPE,16758,2,6,00000000000,8801971507671,0,0,,FFFFFFFFFFFFFFFFFFFFFFFF,3 
1,14286085,10114405,142,601124225298,1,1,1,1062895388906858,1,601124225298,1,1062895388906858F,41,170523,170523,1,1,235045,235045,0,1,255,1,0,BINDMA,0,BWGKPA,39285,2,6,00000000000,62895388906858,0,,FFFFFFFFFFFFFFFFFFFFFFFF,2 

我想,然後進入下一個文件,文件2並重覆上述相同的過程。然後這應該繼續,直到完成一個目錄中的所有文件。

任何幫助,非常感謝。謝謝!

回答

0

您可能會將指定分隔符的字段切爲逗號。並且你使用sed命令來刪除你需要的替換字符。

cat filename | cut -d',' -f28 |sed s/(.*)./$1/g; 
相關問題