Re: On removing ^M
On Mon, May 09, 2005 at 12:34:08AM +0300, Giorgos Keramidas wrote: No tool is needed, as long as you have FreebSD's shell, sed grep: $ find . | while read fname ;do if grep '^M' ${fname} /dev/null 21 ;then sed -i '' -e 's/^M//g' ${fname} fi done Wouldn't this also catch directories or special files with ^M in them? I'd add a -type f to find to avoid errors while trying to write to a directory: $ find . -type f | while read fname ;do if grep '^M' ${fname} /dev/null 21 ;then sed -i '' -e 's/^M//g' ${fname} fi done Regards, -cpghost. -- Cordula's Web. http://www.cordula.ws/ ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: On removing ^M
On 2005-05-09 12:21, cpghost [EMAIL PROTECTED] wrote: On Mon, May 09, 2005 at 12:34:08AM +0300, Giorgos Keramidas wrote: No tool is needed, as long as you have FreebSD's shell, sed grep: $ find . | while read fname ;do if grep '^M' ${fname} /dev/null 21 ;then sed -i '' -e 's/^M//g' ${fname} fi done Wouldn't this also catch directories or special files with ^M in them? I'd add a -type f to find to avoid errors while trying to write to a directory: $ find . -type f | while read fname ;do if grep '^M' ${fname} /dev/null 21 ;then sed -i '' -e 's/^M//g' ${fname} fi done Yes. You're right, of course :-) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: On removing ^M
- Original Message - From: Giorgos Keramidas [EMAIL PROTECTED] To: cpghost [EMAIL PROTECTED] Subject: Re: On removing ^M Date: Mon, 9 May 2005 13:29:46 +0300 On 2005-05-09 12:21, cpghost [EMAIL PROTECTED] wrote: On Mon, May 09, 2005 at 12:34:08AM +0300, Giorgos Keramidas wrote: No tool is needed, as long as you have FreebSD's shell, sed grep: $ find . | while read fname ;do if grep '^M' ${fname} /dev/null 21 ;then sed -i '' -e 's/^M//g' ${fname} fi done Wouldn't this also catch directories or special files with ^M in them? I'd add a -type f to find to avoid errors while trying to write to a directory: $ find . -type f | while read fname ;do if grep '^M' ${fname} /dev/null 21 ;then sed -i '' -e 's/^M//g' ${fname} fi done Yes. You're right, of course :-) Very good! Thank you all! So in conclusion, does this sh script look good? I mean, can the first 3 commands be put like that? $ chown -R fafa:wheel * $ find . -type d -exec chmod 755 {} \; $ find . -type f -exec chmod 644 {} \; $ find . -type f | while read file ; do if grep '^M' ${file} /dev/null 21 ; then sed -i '' -e 's/^M//g' ${file} fi done Forever grateful! That's me. -- Fafa Hafiz Krantz Research Designer @ http://www.home.no/barbershop Enlightened @ http://www.home.no/barbershop/smart/sharon.pdf -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: On removing ^M
On 2005-05-09 14:13, Fafa Hafiz Krantz [EMAIL PROTECTED] wrote: So in conclusion, does this sh script look good? I mean, can the first 3 commands be put like that? $ chown -R fafa:wheel * $ find . -type d -exec chmod 755 {} \; $ find . -type f -exec chmod 644 {} \; Yes. That looks fine. You may want to quote those {} characters. Some shells may interpret them. Compare, for instance, the output of the following two commands in tcsh: % echo {a,b,c} % echo '{a,b,c}' ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: On removing ^M
Textpad as a editor on Windows works great -- Chris. I love deadlines. I especially love the whooshing sound they make as they fly by... - Douglas Adams, 'Hitchhiker's Guide to the Galaxy' - Original Message - From: Fafa Hafiz Krantz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, May 08, 2005 9:20 PM Subject: On removing ^M Good day all! I am aware of the port unix2dos (dos2unix) as a tool to remove ^Ms from ASCII files. But if you execute dos2unix in a directory where some files contain ^M (CR/LF) and some files don't (CR), then dos2unix will make a mess of those files who don't. I am wondering what is needed (what tool or what code) to do a mass (recursive) removal of ^Ms? Thanks! -- Fafa Hafiz Krantz Research Designer @ http://www.home.no/barbershop Enlightened @ http://www.home.no/barbershop/smart/sharon.pdf -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: On removing ^M
On Sun, 08 May 2005 12:53:06 -0700 tr -d \r input-file output-file Or: perl -pi -e 's/\015//' *.c which will edit all .c files in place, or: perl -pi.bak -e's/\015//' *.c (I forget to add a for or foreach line!) If there is a large number of files (i.e. if the command is too long - error: Argument list too long) try something like: find -X . -type f -print | xargs -L 1 perl -pi.bak -e's/\015//' Don't forget to do a backup copy of your original files! If filenames should be protected (enclosed in or '' ) the -X find option complains and skip them. -- regisr ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: On removing ^M
On 2005-05-08 14:20, Fafa Hafiz Krantz [EMAIL PROTECTED] wrote: Good day all! I am aware of the port unix2dos (dos2unix) as a tool to remove ^Ms from ASCII files. But if you execute dos2unix in a directory where some files contain ^M (CR/LF) and some files don't (CR), then dos2unix will make a mess of those files who don't. I am wondering what is needed (what tool or what code) to do a mass (recursive) removal of ^Ms? No tool is needed, as long as you have FreebSD's shell, sed grep: $ find . | while read fname ;do if grep '^M' ${fname} /dev/null 21 ;then sed -i '' -e 's/^M//g' ${fname} fi done ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: On removing ^M
+++ Fafa Hafiz Krantz [freebsd] [08-05-05 14:20 -0500]: | | Good day all! | | I am aware of the port unix2dos (dos2unix) as a tool to | remove ^Ms from ASCII files. | | But if you execute dos2unix in a directory where some files | contain ^M (CR/LF) and some files don't (CR), then dos2unix | will make a mess of those files who don't. | | I am wondering what is needed (what tool or what code) to | do a mass (recursive) removal of ^Ms? | | Thanks! - Check out the archive. This question is asked many times before. - Answer: 'col -bx old.file new.file' Regards, Shantanoo ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]