Delete a line in a file by script
If I in one script to place the line:
echo “deb ftp://ftp.videolan.org/pub/videolan/ubuntu to dapper universe” >> /etc/apt/sources.list this adds a repository sources.list. It has some form to erase a line of a file or commenting, by one script? |
Do you mean that you want a command that will delete or modify a line based on content?
SED is the tool I know the best. Suppose you want to delete all lines beginning with "dog": sed -i '/^dog/ d' filename Or, add the comment character to all lines containing "dog": sed -i '/dog/ s/^/#/' filename Best SED tutorial I have seen (plus other good stuff): http://www.grymoire.com/Unix/ |
Code:
sed -i~ '/address/d' Code:
sed -i~ '/address/s/^/#/' -- Pixellany beat me to it - fancy formatting slows ya down. :) |
All times are GMT -5. The time now is 06:26 PM. |