Skip to main content
added 4 characters in body
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 118

try

sed 's/[^#]contents^[^#]*contents of line.*/updated contents/' test-file

or with the start of line anchor ^, and you know that line start with content ... , you could do:

sed 's/^contents of line.*/updated contents/' test-file

If you know which line you are going to update, you can change directly with its address line number like.

sed '2s/content of line.*/updated content/' test-file

add -i when you were happy with the result.

try

sed 's/[^#]contents of line.*/updated contents/' test-file

If you know which line you are going to update, you can change directly with address line number like.

sed '2s/content of line.*/updated content/' test-file

add -i when you were happy with the result.

try

sed 's/^[^#]*contents of line.*/updated contents/' test-file

or with the start of line anchor ^, and you know that line start with content ... , you could do:

sed 's/^contents of line.*/updated contents/' test-file

If you know which line you are going to update, you can change directly with its address line number like.

sed '2s/.*/updated content/' test-file

add -i when you were happy with the result.

Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 118

try

sed 's/[^#]contents of line.*/updated contents/' test-file

If you know which line you are going to update, you can change directly with address line number like.

sed '2s/content of line.*/updated content/' test-file

add -i when you were happy with the result.