The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Need to serach if a new line character exists on the last line in a file sunilbm78 UNIX for Dummies Questions & Answers 10 02-29-2008 02:15 PM
Replace certain character with a new a new line. djsal Shell Programming and Scripting 8 01-11-2008 12:59 PM
how to add new line character ravi.sadani19 Shell Programming and Scripting 3 11-23-2007 03:26 AM
delete a line based on first character of the line borncrazy UNIX for Dummies Questions & Answers 2 12-06-2005 03:27 PM
end of the line character zomboo Shell Programming and Scripting 5 12-30-2004 05:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-11-2004
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
stripping last character from end of each line

Hi, sorry for being dumb but I have a file with a variable amount of records (day to day it differs) but is fixed at 80 characters wide. Unfortunately the 80th and last charachter in each line is a "^M" carriage return character which i want to get rid of. Is there a really easy command that i can use to strip this character off the end of each line (as i say the number of lines is totally variable)


any help would be greatly appreciated
Gary
  #2 (permalink)  
Old 05-11-2004
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
The command you want is called "dos2unix" although depending on your system may be called "dos2ux" or "dos2aix" etc.
  #3 (permalink)  
Old 11-17-2005
Gerry405 Gerry405 is offline
Registered User
  
 

Join Date: Jun 2005
Location: Alexandria, Scotland
Posts: 46
stripping out end of line chars

Are there no other ways to do this besides installing a program, I need something as well at the Unix end shell script wise


Quote:
Originally Posted by Ygor
The command you want is called "dos2unix" although depending on your system may be called "dos2ux" or "dos2aix" etc.
  #4 (permalink)  
Old 11-18-2005
grasper grasper is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 45
You could use sed, something like:-

sed 's/^M$//' file.txt > newfile.txt (Ctrl-v, then enter for ^M character)

or if the record-length's always going to be invariable, you could use cut.
  #5 (permalink)  
Old 11-18-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Simple and effective:
Code:
strings filename > filename.new; mv filename.new filename
  #6 (permalink)  
Old 11-21-2005
Gerry405 Gerry405 is offline
Registered User
  
 

Join Date: Jun 2005
Location: Alexandria, Scotland
Posts: 46
end of line chars

thanks for that, I tried it this morning and it's just the job...many thanks to all....
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 04:24 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