/ Published in: Bash
For deleting a line from a file without open the file you can use sed.
For example, it has been very useful many times for me after anoying messages from ssh when a host I use to connect change the IP...
And sometimes you don't know the line number but you know a specific word from this line.
For example, it has been very useful many times for me after anoying messages from ssh when a host I use to connect change the IP...
And sometimes you don't know the line number but you know a specific word from this line.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# delete the line 18 from '~/.ssh/known_hosts' file sed -i '18 d' ~/.ssh/known_hosts # also sed -i 18d ~/.ssh/known_hosts # delete few lines # delete 6 lines from line 8 sed -i 8,+6d file.txt # delete the line where is 'TO DELETE' sed -i '/TO DELETE/ d' file.txt