home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10688 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.9 KB  |  67 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!walter!fork!snk
  3. From: snk@fork.bae.bellcore.com (Samuel Kamens)
  4. Subject: Re: need script to rename uppercase filenames
  5. Message-ID: <1992Sep3.135042.29363@walter.bellcore.com>
  6. Keywords: script,tar,msdos
  7. Sender: news@walter.bellcore.com
  8. Nntp-Posting-Host: fork.bae.bellcore.com
  9. Reply-To: snk@bae.bellcore.com
  10. Organization: Bell Communications Research
  11. References:  <699@svcs1.UUCP>
  12. Date: Thu, 3 Sep 92 13:50:42 GMT
  13. Lines: 52
  14.  
  15. In article <699@svcs1.UUCP>, slix@svcs1.UUCP (Bill Miller) writes:
  16. > Hi, everyone.
  17. > I'm fairly new to unix, and I need a script or procedure to do the following:
  18. >  
  19. > I have some source code in DOS (many separate files) that I tarred under
  20. > DOS and untarred under 386BSD.  The big problem is that all the files
  21. > came through in UPPERCASE and I need a script to mv (rename) them all
  22. > to lowercase quickly.
  23. >  
  24. > Since they're in DOS text format, I realize I also need to strip the 
  25. > extra carriage returns on each line.  I've been successful in doing this
  26. > with:
  27. >  
  28. >   cat (file) | tr -d '\015' > (newfile)
  29. >  
  30. > It would be nice to combine both of these so that I could rename the
  31. > files to uppercase and strip the extra newlines all in one fell swoop
  32. > instead of doing it one file at a time.
  33.  
  34.  
  35. Try this:
  36.  
  37. -------------------- CUT HERE ----------------------
  38. #!/bin/ksh
  39. # Script to rename a list of files to its lowercase equivalent while 
  40. # stripping extra carriage returns
  41. #
  42.  
  43. USAGE: $0 FILE1 FILE2 FILE3 ...
  44.  
  45. for i in $*
  46. do
  47.     lowfile=`echo $i | tr [A-Z] [a-z]`
  48.     
  49.     cat ${i} | tr -d '\015' > ${lowfile}
  50.     # you could do rm $i here if you want
  51. done
  52. -------------------- CUT HERE ----------------------
  53.  
  54. You could also do this with a one-liner:
  55.  
  56.     cat $1 | tr -d '\015' > `echo $1 | tr [A-Z] [a-z]`
  57.  
  58. Sam
  59.  
  60. -- 
  61. Sam Kamens                    Bell Communications Research
  62. snk@bae.bellcore.com                Phone: (908) 699-7509
  63. 444 Hoes Lane  Room RRC 1D-210
  64. Piscataway, NJ 08854
  65.