3 `\s` and `-i` are GNU extensions
source | link

Simply with GNU sed, using -i to replace text directly in the file  :

sed -i 's:\(.*\s\)\(.*\s\)\(.*\):\1\21:g' textfile

The columns are matched by regex groups in the parenthesis, reusing them with \1 and \2 and then using a "1" to replace the last group.

In this use case, the solution proposed using awk is nice and short as well.

Simply with sed, using -i to replace text directly in the file  :

sed -i 's:\(.*\s\)\(.*\s\)\(.*\):\1\21:g' textfile

The columns are matched by regex groups in the parenthesis, reusing them with \1 and \2 and then using a "1" to replace the last group.

In this use case, the solution proposed using awk is nice and short as well.

Simply with GNU sed, using -i to replace text directly in the file:

sed -i 's:\(.*\s\)\(.*\s\)\(.*\):\1\21:g' textfile

The columns are matched by regex groups in the parenthesis, reusing them with \1 and \2 and then using a "1" to replace the last group.

In this use case, the solution proposed using awk is nice and short as well.

2 added 124 characters in body
source | link

Simply with sed, using -i to replace text directly in the file :

sed -i 's:\(.*\s\)\(.*\s\)\(.*\):\1\21:g' textfile

The columns are matched by regex groups in the parenthesis, reusing them with \1 and \2 and then using a "1" to replace the last group.

In this use case, the solution proposed using awk is nice and short as well.

Simply with sed, using -i to replace text directly in the file :

sed -i 's:\(.*\s\)\(.*\s\)\(.*\):\1\21:g' textfile

In this use case, the solution proposed using awk is nice and short as well.

Simply with sed, using -i to replace text directly in the file :

sed -i 's:\(.*\s\)\(.*\s\)\(.*\):\1\21:g' textfile

The columns are matched by regex groups in the parenthesis, reusing them with \1 and \2 and then using a "1" to replace the last group.

In this use case, the solution proposed using awk is nice and short as well.

1
source | link

Simply with sed, using -i to replace text directly in the file :

sed -i 's:\(.*\s\)\(.*\s\)\(.*\):\1\21:g' textfile

In this use case, the solution proposed using awk is nice and short as well.