Regarding adding two lines at the end (104 Views)
Reply
Regular Advisor
vind123
Posts: 106
Registered: ‎06-26-2006
Message 1 of 5 (104 Views)

Regarding adding two lines at the end

I am posting this again since i need an workaround and submit it quickly.
I have a file netmap.cfg ending with contents and a newline at the end of file as below

fep:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=6:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=fep;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:
\n

I want to change the file contents as below with adding last two line tcp.max.time.to.wait and runstep.max.time.to.wait=300:

fep:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=6:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=fep;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:
:tcp.max.time.to.wait=180:\
:runstep.max.time.to.wait=300:
\n

I have a file tempfile
>cat tempfile
:tcp.max.time.to.wait=180:\
:runstep.max.time.to.wait=300:


If i do a cat tempfile >> netmap.cfg
it's listing as below

fep:\
:conn.retry.stwait=00.00.30:\
:conn.retry.stattempts=3:\
:conn.retry.ltwait=00.10.00:\
:conn.retry.ltattempts=6:\
:contact.name=:\
:contact.phone=:\
:descrip=:\
:sess.total=255:\
:sess.pnode.max=128:\
:sess.snode.max=127:\
:sess.default=1:\
:comm.info=fep;1364:\
:comm.transport=tcp:\
:comm.bufsize=4096:\
:pacing.send.delay=0:\
:pacing.send.count=0:

:tcp.max.time.to.wait=180:\
:runstep.max.time.to.wait=300:
\n
How do i overcome this unnecessary newline? Is there anything i can try out.
Honored Contributor
Peter Godron
Posts: 4,470
Registered: ‎02-13-2002
Message 2 of 5 (104 Views)

Re: Regarding adding two lines at the end

Hi,
From sed one-liners:

sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' file > file1
cat tempfile >> file1
mv file1 netmap.cfg

Honored Contributor
spex
Posts: 1,367
Registered: ‎05-14-1996
Message 3 of 5 (104 Views)

Re: Regarding adding two lines at the end

Hi,

# grep -xv '' < netmap.cfg > netmap.cfg.new

PCS
Esteemed Contributor
Arturo Galbiati
Posts: 830
Registered: ‎02-10-2003
Message 4 of 5 (104 Views)

Re: Regarding adding two lines at the end

Hi,
this runs fine on my hp-ux 11i:
cat<>netmap.cfg
:tcp.max.time.to.wait=180:\
:runstep.max.time.to.wait=300:
!

HTH,
Art
Honored Contributor
Peter Godron
Posts: 4,470
Registered: ‎02-13-2002
Message 5 of 5 (104 Views)

Re: Regarding adding two lines at the end

Hi,
couple of solutions here.
Can you please update the thread.
If the answers are not right, please let us know.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.