Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Removing Carriage Return and or line feed from a file

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 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>

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
Old Unix and Linux 02-18-2005
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
Join Date: Feb 2005
Last Activity: 22 September 2017, 9:00 AM EDT
Location: Foxborough, MA
Posts: 8,190
Thanks: 226
Thanked 782 Times in 730 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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 09:37 AM.