The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Article Feedback - Stripping ^M from your files
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 shell script for multiple files
Author: jason kawaja 
Date:   26-09-02 21:34

#!/usr/local/bin/bash
echo "Removing ^M's for the following files..."
for file in $*; do
echo "----> $file"
tr -d "\015" < $file > $file.$$
mv $file.$$ $file
done
echo "Done."
exit 0

Reply To This Message
 
 Re: shell script for multiple files
Author: maximus 
Date:   14-01-05 21:35

for those that have access to the rename command:
rename .jpg^M .jpg *.jpg^M

that is entered in the directory containing the offending files like:
rename SPACE .jpg CNTRL-V CNTRL-M SPACE .jpg SPACE *.jpg CNTRL-V CNTRL-M ENTER.

CNTRL-V CNTRL-M is required to get the actual CNTRL-M into the command line.
the .jpg is an example extention, but could really be anything... .html, .txt, etc.

That'll take off the ^M from all the file names.

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org