Adding # to the first line
Dears,
How Does sed or other command edit the 1st line in a file and comments it? Meaning add "#" to the first line in a file for example? Summary: Insert # to the first line. Before: Comment me please. sed command or another command After: #Comment me please. ------And if possible a way to remove the "#" using command line. Thanks. |
Code:
$ sed -i '1s/^/#/' file # add |
Hi,
To add: Code:
sed '1s/^/#/' file To remove: Code:
sed '1s/^#//' file Hope this helps. |
To add:
Code:
sed -e '1s/\(.*\)/#\1/' filename Code:
sed -e '1s/^#//' filename |
Thanks guys! I need to google for a good tutorial... since sed has alots of mumbojumbos :0) /\/\/'s/g'{/\/\/\ etc.. :))
|
Hi,
Here's one site that deals with sed: Sed - An Introduction and Tutorial by Bruce Barnett If you like paper books, have a look at O'Reilly's Sed & Awk (isbn 1-56592-225-5) Hope this helps. |
Here we go: http://www.grymoire.com/Unix/Sed.html
|
All times are GMT -5. The time now is 01:31 AM. |