Can I use sed to replace selected characters, for example H => X, 1 => 2, but first seek forward so that characters in first groups are not replaced.
Sample data:
"Hello World";"Number 1 is there";"tH1s-Has,1,HHunKnownData";
How it should be after sed:
"Hello World";"Number 1 is there";"tX2s-Xas,2,XXunKnownData";
What I have tried:
Nothing really, I would try but everything I know about sed expressions seems to be wrong.
Ok, I have tried to capture ([^;]+) and “skip” (get em back using ´\1\2´…) first groups separated by ;, this is working fine but then comes problem, if I use capturing I need to select whole group and if I don’t use capturing I’ll lose data.
This is possible with
sed, but is kinda tedious. To do the translation if field number$FIELDyou can use the following:Or, reducing the number of brackets with
GNU sed:Example:
There may be a simpler way that I didn’t think of, though.