我試圖替換以下字符串例如: 從AWK與如果條件
['55',2,1,10,30,23],
到
['55',2,555,10,30,23],
OR
['55',2,1,10,30,23],
到
['55',2,1,10,9999,23],
我四處搜尋,找到這個:
$ echo "[55,2,1,10,30,23]," | awk -F',' 'BEGIN{OFS=","}{if($1=="[55"){$2=10}{print}}'
[55,10,1,10,30,23],
,但它不是我的情況下工作,因爲我如果條件有「'」周圍$ 1的值:
$ echo "['55',2,1,10,30,23]," | awk -F',' 'BEGIN{OFS=","}{if($1=="['55'"){$2=10}{print}}'
['55',2,1,10,30,23],
解釋這背後的邏輯? – 2015-01-21 09:33:39