我試圖用awk like this替換某個文件的某一列。我可以得到它的工作使用Awk將不會替換所有列
awk '{ sub(/4$/, "Q", $6) }1' temp2.txt
然而在列6使用
awk '{ sub(/r$/, "Q", $3) }1' temp2.txt
或者「4」來代替「R」,在第3欄,我不能做的「T替換「第4欄
文件的內容是
cat temp2.txt
224245 CO2_Cells_50_V_-100_P_760 r 2016-08-18T13:35:12.337 [email protected] 4
224256 CO2_Cells_100_V_-200_P_760 r 2016-08-18T13:35:15.408 [email protected] 4
224261 CO2_Cells_100_V_-250_P_760 r 2016-08-18T13:35:16.425 [email protected] 4
224262 CO2_Cells_150_V_-250_P_760 r 2016-08-18T13:35:16.426 [email protected] 4
224264 CO2_Cells_250_V_-250_P_760 r 2016-08-18T13:35:17.438 [email protected] 4
224266 CO2_Cells_100_V_-300_P_760 r 2016-08-18T13:35:17.440 [email protected] 4
224267 CO2_Cells_150_V_-300_P_760 r 2016-08-18T13:35:17.442 [email protected] 4
224268 CO2_Cells_200_V_-300_P_760 r 2016-08-18T13:35:17.443 [email protected] 4
224269 CO2_Cells_250_V_-300_P_760 r 2016-08-18T13:35:18.460 [email protected] 4
224271 CO2_Cells_100_V_-350_P_760 r 2016-08-18T13:35:18.463 [email protected] 4
224272 CO2_Cells_150_V_-350_P_760 r 2016-08-18T13:35:18.464 [email protected] 4
224273 CO2_Cells_200_V_-350_P_760 r 2016-08-18T13:35:18.466 [email protected] 4
224274 CO2_Cells_250_V_-350_P_760 r 2016-08-18T13:35:19.539 [email protected] 4
224277 CO2_Cells_150_V_-400_P_760 r 2016-08-18T13:35:19.543 [email protected] 4
224278 CO2_Cells_200_V_-400_P_760 r 2016-08-18T13:35:19.545 [email protected] 4
224279 CO2_Cells_250_V_-400_P_760 r 2016-08-18T13:35:20.649 [email protected] 4
224282 CO2_Cells_150_V_-450_P_760 r 2016-08-18T13:35:20.653 [email protected] 4
224283 CO2_Cells_200_V_-450_P_760 r 2016-08-18T13:35:20.654 [email protected] 4
224287 CO2_Cells_150_V_-500_P_760 r 2016-08-18T13:35:21.718 [email protected] 4
224288 CO2_Cells_200_V_-500_P_760 r 2016-08-18T13:35:21.720 [email protected] 4
224289 CO2_Cells_250_V_-500_P_760 r 2016-08-18T13:35:21.721 [email protected] 4
224522 CO2_Cells_250_V_-450_P_760 r 2016-08-18T14:54:09.720 [email protected] 4
224699 CO2_Cells_50_V_-150_P_760 r 2016-08-18T18:04:18.900 [email protected] 4
沒有'/ [T] /'經過短短'/ T /'的好處。 –
同意,如果需要更換多個char,則更多的是一個示例。 –