bash - Replace text on a specific line
by fuqalufo from LinuxQuestions.org on (#59QE0)
Hello ;)
Code:sed '4 s/A/B/' testfile.txtThis command on the 4th line finds A and replaces it with B.
How to write it in a bash script when a string is specified as a variable? it is necessary that only in the specified line of the text file change A to B. For some reason, I get it on all lines.
Thanks.


Code:sed '4 s/A/B/' testfile.txtThis command on the 4th line finds A and replaces it with B.
How to write it in a bash script when a string is specified as a variable? it is necessary that only in the specified line of the text file change A to B. For some reason, I get it on all lines.
Thanks.