I am a complete novice when it comes to interfacing with computers, but I'm working on a project that I can't keep up with without making a script, so I need help.
I have two strings in a single line in my files that I want to replace using sed. The problem is they're very similar and I can't figure out how to replace them independently.
the line I want to replace is this:
*xyzfile 0 1 somefilebeingpointedto.xyz
I want to end up with this line:
*xyz 0 1
since the 0 and 1 change from file to file and there's no conserved string before the '.xyz' in the last string, I don't know how to do this or to simply replace the entire line.
What I have been trying to use is the following two sed lines:
sed -i 's/^.*xyzfile/\*xyz/' myfile.inp
sed -i 's/^.\.xyz/" "/' myfile.inp
order doesn't make a difference and it seems like the sed is simply not treating the period as a part of the string in the second line.
If there's a better way of accomplishing this, I'm all ears! Thanks
sed 's/^\*xyzfile\(.*\) .*/*xyz\1/' file
. – Ed Morton Aug 03 '19 at 20:14