User Tools

Site Tools


sed:change:change_from_nth_occurrence_in_a_line

SED - Change - Change from Nth occurrence in a line

Use the combination of /1, /2 etc and /g to replace all the patterns from the Nth occurrence of a pattern in a line.

The following sed command replaces the third, fourth, fifth… “unix” word with “linux” word in a line.

sed 's/unix/linux/3g' filename
sed/change/change_from_nth_occurrence_in_a_line.txt · Last modified: 2020/08/18 00:14 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki