Skip to main content
added 223 characters in body
Source Link
NickD
  • 3k
  • 1
  • 14
  • 23

You remember things by parenthesizing what you want to remember in the match part of the command and you recall the remembered things using \N with some number N to replace it with what the Nth set of parens in the matching part remembered:

sed -E 's/(L[0-9]{1,2})_name([0-9]+)/\1_new_name\2/g' file.csv

See the sed manual for the full details.

EDIT: I should point out that you are allowed to use various special chars like ()[]{}+ without escaping them because you have specified -E i.e. extended regular expressions. Again the manual provides full details.

You remember things by parenthesizing what you want to remember in the match part of the command and you recall the remembered things using \N with some number N to replace it with what the Nth set of parens in the matching part remembered:

sed -E 's/(L[0-9]{1,2})_name([0-9]+)/\1_new_name\2/g' file.csv

See the sed manual for the full details.

You remember things by parenthesizing what you want to remember in the match part of the command and you recall the remembered things using \N with some number N to replace it with what the Nth set of parens in the matching part remembered:

sed -E 's/(L[0-9]{1,2})_name([0-9]+)/\1_new_name\2/g' file.csv

See the sed manual for the full details.

EDIT: I should point out that you are allowed to use various special chars like ()[]{}+ without escaping them because you have specified -E i.e. extended regular expressions. Again the manual provides full details.

Source Link
NickD
  • 3k
  • 1
  • 14
  • 23

You remember things by parenthesizing what you want to remember in the match part of the command and you recall the remembered things using \N with some number N to replace it with what the Nth set of parens in the matching part remembered:

sed -E 's/(L[0-9]{1,2})_name([0-9]+)/\1_new_name\2/g' file.csv

See the sed manual for the full details.