General
Showing results for 
Search instead for 
Do you mean 

Regarding adding two lines at the end

Regular Advisor

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.
4 REPLIES
Honored Contributor [Founder]

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

Re: Regarding adding two lines at the end

Hi,

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

PCS
Esteemed Contributor [Founder]

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 [Founder]

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.