Hello everyone. I got a document that fields are separated by a colon(:) where I need to change the second field from time to time. The document looks like this:
name1:UhX.PPFW7$YhPMH0BISY:23490::::::
name2:1./0oV$GEs6WJpE$LHXhy:19239:0:29388:2::29302:
...
The second field of the file will change occasionally and may contain a couple regular expression characters ($ .) and a forward slash.
I'd like to replace only the second field as the data that follows it may be different in the future. If I do:
sed -e "s~^name2:.*:~name2:aTest\$repl.ace:~g" tst
The text to the right of the second column is lost:
name2:aTest$repl.ace:
(i.e. the '19239:0:29388:2::29302:'). Is there a way that sed can replace a varying column and preserve the rest of the line? Or, possibly, is there a better program to do this?