I have a requirement where we need to replace a word in a file which can be different everytime I execute the script, the content of the file is
class DynamicContentToReplace > Something
Here I need to use sed command to replace [DynamicContentToReplace] with RequiredContent. The [DynamicContentToReplace] could include everything except white spaces.
Assumptions we can take is that the file will only contain one such line containing class word
Desired Output
class RequiredContent > Something
I have tried the following command
sed -e "s/\(class \)\([^\s]+\)/\1RequiredContent/" but it still does not replace the content. What am i missing here. I have gone through this post as well. But couldn't get the solution.
> Somethingpart ? Something on the same line?> Somethingpart is on the same line.classappear on any other lines? Canfoo bar >appear on other lines? How can we identify the bit that needs to change?classword will only appear once in the entire file. We can identify the word to replace using that