The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extra/parse lines from a file between unque lines through the file jouuu Shell Programming and Scripting 5 01-28-2009 12:42 PM
Substitute specific lines with lines from another file rahmathulla Shell Programming and Scripting 1 01-11-2009 11:45 AM
Eliminating characters between two expressions arsheshadri HP-UX 1 06-26-2008 09:00 AM
UrgentPlease: compare 1 value with file values eliminating special characters kittusri9 Shell Programming and Scripting 10 04-28-2008 05:51 AM
Eliminating whitespaces during reading of a field. videsh77 Shell Programming and Scripting 4 12-13-2004 12:52 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-29-2009
KornFire's Avatar
KornFire KornFire is offline
Registered User
  
 

Join Date: Aug 2008
Location: Bangalore, India.
Posts: 5
Eliminating CR (new lines) from a file.

Hi all, I made a C++ program in dos (in dev-C++) and uploaded it on Solaris box. On opening that file with 'vim' editor i found that there is some extra new lines after each written code line. I tried to find out is the file is in dos or in unix format, with 'file' command,and i got "<file-name>.h: ASCII C++ program text". After which i used 'dos2unix' command which shows 'converting file to unix format' but new-lines didn't disappear. Any help on this will be most welcome.

Thanks,
  #2 (permalink)  
Old 01-29-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,311

Code:
tr -d '\015' < infile > outfile

  #3 (permalink)  
Old 01-29-2009
KornFire's Avatar
KornFire KornFire is offline
Registered User
  
 

Join Date: Aug 2008
Location: Bangalore, India.
Posts: 5
sorry but your command didn't work. But, i read man pages and used

Code:
tr -s '\n' < infile > outfile

This is not exactly i wanted. the above command eliminated all blank lines. Still it'll be hard to insert a new line to separate each code-block in 3000 line code. If there is any other way to do this, i am happy to learn more about that.
  #4 (permalink)  
Old 01-29-2009
KornFire's Avatar
KornFire KornFire is offline
Registered User
  
 

Join Date: Aug 2008
Location: Bangalore, India.
Posts: 5
hi,
I'm looking for a command with which i can change double or repeated (Unix) new line to single new line.
Thanks,
  #5 (permalink)  
Old 01-29-2009
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
I think what you're after is replacing multiple blank lines with a single blank (the ref to "newline" is slightly confusing). Try:


Code:
nawk 1 RS= ORS="\n\n" infile

or

Code:
sed '/./,/^$/!d' infile

HTH
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0