The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to remove old files without recursion? nir_s Shell Programming and Scripting 5 04-27-2008 07:43 AM
Script to remove log files kiranherekar Shell Programming and Scripting 1 03-01-2006 10:24 PM
Want to remove files from unix directory yogi_chavan HP-UX 1 08-12-2005 01:27 PM
remove some files on a condition.. ST2000 Shell Programming and Scripting 4 08-27-2002 06:26 PM
remove files Nisha Shell Programming and Scripting 7 06-25-2002 09:04 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-15-2005
Registered User
 

Join Date: Jul 2005
Posts: 27
Remove ^M (CR) from Unix Files

Is there any way we could remove the "^M" from files on unix?

and also what is the best way to count the TABS in a TAB delimited file per record?

Thanks,
AC
Reply With Quote
Forum Sponsor
  #2  
Old 07-15-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Quote:
Originally Posted by acheepi
Is there any way we could remove the "^M" from files on unix?
search the archives
Quote:
Originally Posted by acheepi
and also what is the best way to count the TABS in a TAB delimited file per record?
Code:
nawk -F"`/bin/echo '\t'`" '{print FNR, NF}' myFile
Reply With Quote
  #3  
Old 07-17-2005
Registered User
 

Join Date: Jun 2004
Posts: 146
You can try also :
cat file1 | tr -d "\r" > file2

Regards,
Nir
Reply With Quote
  #4  
Old 07-17-2005
Registered User
 

Join Date: Jul 2005
Posts: 137
Quote:
Originally Posted by nir_s
You can try also :
cat file1 | tr -d "\r" > file2

Regards,
Nir
Is cat needed?

Code:
tr -d "\r" <file1 >file2
Reply With Quote
  #5  
Old 07-17-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
Code:
strings file_name > file_name_without_control_chars
Cheers
Reply With Quote
  #6  
Old 07-18-2005
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,262
sed 's/^M$//' <file> > <newfile>

( "^M" has to be entered as CTRL-M)

Alternative possibilities include "dos2unix" and similar programs.

Nearly every program is able to remove trailing LF-characters it seems. ;-))

bakunin
Reply With Quote
  #7  
Old 07-18-2005
Registered User
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
You have to use dos2unix (linux) or dos2ux (hp-ux) for this. Encoding is getting different from dos to unix with ^M character.

hth.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0