I have a file which I must iterate through several times, running it with python each time. How can I remove or add characters from specific lines in shell?
for an example file ex.file,
$ cat ex.file
stuff
more stuff
more stuff
more stuff
#<- remove this character
<-add a pund sign here
more stuff
more stuff
my desired output would be:
$ cat ex.file
stuff
more stuff
more stuff
more stuff
<- remove this character
#<-add a pund sign here
more stuff
more stuff
To add a # at the start of line 6:
sed '6 s/^/#/' ex.file
To remove the leading # from line 5:
sed '5 s/^#//' ex.file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With