I'm looking for other alternatives/more intelligent 1 liner for following command, which should add a value to a requested column number. I tried following following sed command works properly for adding value 4 to the 4th column. [Need: As i have such file which contains 1000 records & many times i need to add a column in between at any position.] My approch is sutaible for smaller scale only.
cat 1.txt
1|2|3|5
1|2|3|5
1|2|3|5
1|2|3|5
sed -i 's/1|2|3|/1|2|3|4|/g' 1.txt
cat 1.txt
1|2|3|4|5
1|2|3|4|5
1|2|3|4|5
1|2|3|4|5
thansk in advance.