home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2006 January / PCA126_DVD.iso / ADVISORS / phpBB-2.0.17 / phpBB2 / contrib / fixfiles.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2004-03-25  |  831 b   |  29 lines

  1. #!/bin/bash
  2. # Remove all those annoying ^M characters that Winblows editor's like to add
  3. # from all files in the current directory and all subdirectories.
  4. #
  5. # Written by: Jonathan Haase.
  6. #
  7. # UPDATE: 7/31/2001: fix so that it doesn't touch things in the images directory
  8. #
  9. # UPDATE: 12/15/2003: Fix so that it doesn't touch any "non-text" files
  10. #
  11.  
  12. find . > FILELIST.$$
  13. grep -sv FILELIST FILELIST.$$ > FILELIST2.$$
  14. grep -sv $(basename $0) FILELIST2.$$ > FILELIST.$$
  15. grep -sv "^\.$" FILELIST.$$ > FILELIST2.$$
  16. file -f FILELIST2.$$  |grep text | sed -e 's/^\([^\:]*\)\:.*$/\1/' > FILELIST
  17. file -f FILELIST2.$$  |grep -sv text | sed -e 's/^\([^\:]*\)\:.*$/Not Modifying file: \1/'
  18. rm FILELIST2.$$
  19. rm FILELIST.$$
  20.  
  21. for i in $(cat FILELIST); do
  22.     if [ -f $i ]; then       
  23.         sed -e s/
  24. //g $i > $i.tmp
  25.           mv $i.tmp $i
  26.     fi    
  27. done
  28. rm FILELIST
  29.