I'm a windows-based programmer who has recently been given the task of adding some simple functionality to a sister company product that is written in C and running on Fedore Project. My task is to modify the contents of a text file.
The data in the file is structured so that each unique value is delimited by the character |; as such:
value1|value2|value3|value4|value5|value6
it is possible that zero to all of the values could be null, in which case the data could look like this:
value1||value3|value4|value5|
The question is this: Using sed, is there a way to replace data between two specific delimiters in the string? For example, I want to completely replace the substring 'value4' with the string 'hereWeGo', as such:
value1|value2|value3|hereWeGo|value5|value6
or in the case of there being no data is this place, add it. See below;
BEFORE -> value1||value3||value5|value6
AFTER -> value1||value3|hereWeGo|value5|value6
The data in the file is structured so that each unique value is delimited by the character |; as such:
value1|value2|value3|value4|value5|value6
it is possible that zero to all of the values could be null, in which case the data could look like this:
value1||value3|value4|value5|
The question is this: Using sed, is there a way to replace data between two specific delimiters in the string? For example, I want to completely replace the substring 'value4' with the string 'hereWeGo', as such:
value1|value2|value3|hereWeGo|value5|value6
or in the case of there being no data is this place, add it. See below;
BEFORE -> value1||value3||value5|value6
AFTER -> value1||value3|hereWeGo|value5|value6