Re: add a character to a line...
- From: Jim Cochrane <allergic-to-spam@xxxxxxxxxxxxxxxxxxx>
- Date: 27 Apr 2006 20:55:27 GMT
On 2006-04-27, onlineviewer <lancerset@xxxxxxxxx> wrote:
Hello,
How do you add a word or a character to the beginning of a line in a
file? I want to add a comment '#' where the string 'var' appears in a
file, globally. Like:
#### before:
bla
Var
bla
#### after:
bla
#Var
bla
Thanks,,,
To change the file directly, you can use ed (or ex):
# On every line where var or Var occurs as a word (e.g., exclude
# "variety"), add '#' to the beginning of the line:
echo 'g/\<[vV]ar\>/s/^/#/
wq'|ed file
It's easy to put this in a for loop to process several files.
--
*** Posted via a free Usenet account from http://www.teranews.com ***
.
- Follow-Ups:
- Re: add a character to a line...
- From: onlineviewer
- Re: add a character to a line...
- References:
- add a character to a line...
- From: onlineviewer
- add a character to a line...
- Prev by Date: Re: sigsegv with PAM on Suse 9.0
- Next by Date: Re: sigsegv with PAM on Suse 9.0
- Previous by thread: Re: add a character to a line...
- Next by thread: Re: add a character to a line...
- Index(es):
Relevant Pages
|