Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trimming a newline character

Status
Not open for further replies.

ddrillich

Technical User
Jun 11, 2003
546
US
Good Day,

I changed the value of a control file using vi. Apparently I introduced a newline character. How can I remove it? as it seems that the program that reads the file doesn't handle it well.

! % ==> diff ctlLockFile.09_10_10 ctlLockFile
1c1
< 19768447
\ No newline at end of file
---
19766000

Regards,
Dan

 
Try...
Code:
mv ctlLockFile ctlLockFile.old
cat ctlLockFile.old | tr '\n' '' > ctlLockFile



 
sun [69]-> cat one
1111
sun [70]-> perl -p -i.bak -e 's/\n/ /g;' one
sun [71]->
sun [71]-> cat one
1111 sun [72]-> cat one.bak
1111



A great teacher, does not provide answers, but methods to teach others "How and where to find the answers"

bsh

36 years Bell, AT&T, Lucent, Avaya
Tier 3 for 26 years and counting
 
this way works also but you need space between ticks
'' should have 'space here'

linux [3014]-> cat one
1111
linux [3015]-> mv one one.old
linux [3016]-> cat one.old
1111
linux [3017]-> cat one.old | tr '\n' ' ' > one
linux [3018]-> cat one
1111 linux [3019]->

First example was for solaris10

A great teacher, does not provide answers, but methods to teach others "How and where to find the answers"

bsh

36 years Bell, AT&T, Lucent, Avaya
Tier 3 for 26 years and counting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top