Removing Carriage Return and or line feed from a file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Removing Carriage Return and or line feed from a file

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-18-2005
tbone231 tbone231 is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 18 February 2005, 3:42 PM EST
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Removing Carriage Return and or line feed from a file

Hello I'm trying to write a shell script which can remove a carriage return and/or line feed from a file, so the resulting file all ends up on one line.

So, I begin with a file like this

text in file!<CR>
line two!<CR>
line three!<CR>
END!<CR>

And I want to end up with a file which looks like this:

text in file!line two!line three!END!

Any ideas on how I might tackle this example?
Sponsored Links
    #2  
Old 02-18-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 24 April 2014, 6:33 PM EDT
Location: Foxborough, MA
Posts: 7,541
Thanks: 137
Thanked 539 Times in 506 Posts
tr -d '\n' < file

with nawk:
nawk '{printf}' file
nawk -v ORS='' '1' file

many ways to skin that cat.

Last edited by vgersh99; 02-18-2005 at 03:43 PM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Removing Carriage return in a file after particular string manish8484 Shell Programming and Scripting 7 01-05-2012 02:09 AM
Carriage return or line feed issues sherrod6970 Programming 1 10-30-2009 07:57 PM
Issue with Removing Carriage Return (^M) in delimited file sirahc UNIX for Advanced & Expert Users 7 03-25-2008 05:08 AM
How to insert carriage return before line feed? huey ing Shell Programming and Scripting 2 08-05-2005 01:22 PM
Removing carriage return characters from file b1saini UNIX for Dummies Questions & Answers 3 09-10-2003 09:41 AM



All times are GMT -4. The time now is 07:40 PM.