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 directory with subdirectories and files? ppa108 UNIX for Dummies Questions & Answers 9 1 Week Ago 11:02 PM
read list of filenames from text file and remove these files in multiple directories fxvisions Shell Programming and Scripting 5 08-07-2008 12:59 PM
Display only subdirectories from given directories HAA Shell Programming and Scripting 8 04-25-2007 02:36 AM
Need to remove files older than 30 days except directories malaymaru Shell Programming and Scripting 6 11-13-2006 08:50 PM
Check all files in directories for string and remove.. possible? LordJezo Shell Programming and Scripting 7 11-29-2005 10:00 PM

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

Join Date: Jul 2006
Posts: 2
How to Remove Ctrl M characters in files from directories and its subdirectories

Hi,
How to recursively remove Ctrl M characters in files from a directory and its sub directory ?

I know unix2dos command is there but to remove in bunch of files ... ?


Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 07-28-2006
Registered User
 

Join Date: Jul 2006
Posts: 12
You need to write a script.
Reply With Quote
  #3  
Old 07-28-2006
Registered User
 

Join Date: Jul 2006
Posts: 12
Try modifying with the following script............

for files in *.html;
do
mv $files $files.old
dos2unix $files.old $files
rm -rf $files.old
done
Reply With Quote
  #4  
Old 07-28-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
Code:
find /path/to/files -print | \
while read file
do
     dos2ux "$file" > ./tmpfile
     mv ./tmpfile "$file"
done
Reply With Quote
  #5  
Old 07-28-2006
Registered User
 

Join Date: Jul 2006
Posts: 2
Reply to the script by corleone

Hi corleone,

Iam getting error
/could not open /dev/kbd to get keyboard typed ......


Do I need to save the script in .sh format ?
How do I run the script ? Kindly reply since Iam naive. Iam using unix on solaris.

Thanks
Reply With Quote
  #6  
Old 07-28-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
This error comes from dos2unix and doesn't stop the utility from working. You could simply redirect stderr

dos2unix filename > newfilename 2> /dev/null
Reply With Quote
  #7  
Old 07-28-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
A google seach provided these links:

Link 1
Link 2
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:36 AM.


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