Hello,
From googleing, and trial & error, I found out how to use sed to place a # sign at the beginning of a line while doing it inline.
However, I was wondering if I could replace the searchstring with reading (line by line) the contents of a file.
I found out that sed can read an entire file with the r command. But this doesn't seem like what I want.
I was wondering if I could use sed to read the contents of a file line by line and add a # at the beginning of that line (in a succinct one line).
Side note:
I found that sed can use variables, so I could just write a script that would use while to read the contents of a file and use a variable instead of the searchstring. But was hoping to just use sed.
Thanks in advanced.
From googleing, and trial & error, I found out how to use sed to place a # sign at the beginning of a line while doing it inline.
Code:
sed -i .bak 's/searchstring/#&/' file
However, I was wondering if I could replace the searchstring with reading (line by line) the contents of a file.
I found out that sed can read an entire file with the r command. But this doesn't seem like what I want.
I was wondering if I could use sed to read the contents of a file line by line and add a # at the beginning of that line (in a succinct one line).
Side note:
I found that sed can use variables, so I could just write a script that would use while to read the contents of a file and use a variable instead of the searchstring. But was hoping to just use sed.
Thanks in advanced.