Hello all,

I was hoping someone could steer me in the right direction for a scripting
problem I am having.  The problem I am experiencing is using sed and vi.
The solution I am attempting can most likely be done in perl but not sure
how.  If anyone has any suggestions on how to accomplish it in perl - it
would be much appreciated.


What I am attempting to do is read in a file and add text in specific
locations.  The catch is I need to add text followed by carriage returns
followed by more text and so on.  Below using sed I am attempting to find
something in a file that will always be there like and replace accordingly:

trimmed file contents before:
# Cmnd alias specification




trimmed file contents after:
# Runas_Alias specification
Runas_Alias     AP = acl

# Cmnd alias specification



I can do it on the command line using sed:

sed 's/\(\#\)\( Cmnd alias specification\)/\# Runas_Alias
specification\^JRunas_Alias   AP = acl\1\2/' s1 > s3

Command line works great but when I try to script it using vi it breaks.  In
vi I can't do ctrl-v ctrl-j at all and ctrl-v ctrl-M (or Enter) don't work.
I have been told there is a way to do it in awk but I would rather learn the
perl way if possible.

Again any help would be greatly appreciated:)

Regards,
Evan

Reply via email to