home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / question / 10812 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.6 KB  |  52 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!nucsrl!ddsw1!dattier
  3. From: dattier@ddsw1.mcs.com (David W. Tamkin)
  4. Subject: Re: need script to rename uppercase filenames
  5. Message-ID: <1992Sep8.022910.4634@ddsw1.mcs.com>
  6. Keywords: script,tar,msdos
  7. Organization: Contributor Account at ddsw1, Chicago, Illinois  60657
  8. References: <699@svcs1.UUCP> <1992Sep3.135042.29363@walter.bellcore.com>
  9. Date: Tue, 8 Sep 1992 02:29:10 GMT
  10. X-Disclaimer:  Material posted in this article is the sole responsibility of
  11.                 the poster and does not represent MCSNet or the system owners.
  12. Lines: 38
  13.  
  14. snk@bae.bellcore.com (Sam Kamens) wrote in
  15. <1992Sep3.135042.29363@walter.bellcore.com>:
  16.  
  17. | #!/bin/ksh
  18. | # Script to rename a list of files to its lowercase equivalent while 
  19. | # stripping extra carriage returns
  20. | #
  21. | USAGE: $0 FILE1 FILE2 FILE3 ...
  22. | for i in $*
  23. | do
  24. |     lowfile=`echo $i | tr [A-Z] [a-z]`
  25. |     
  26. |     cat ${i} | tr -d '\015' > ${lowfile}
  27. |     # you could do rm $i here if you want
  28. | done
  29.  
  30. There's nothing in there that requires ksh rather than sh, but since
  31. you're using ksh anyway, how about
  32.  
  33. typeset -l lowfile
  34. for i
  35. do lowfile=$i
  36.    tr -d '\015' < $i > $lowfile
  37. done
  38.  
  39. | You could also do this with a one-liner:
  40. |     cat $1 | tr -d '\015' > `echo $1 | tr [A-Z] [a-z]`
  41.  
  42. That's the third time in this thread I've seen a suggestion to cat one file
  43. to a pipe.  It's better to save a process and
  44.  
  45. tr -d '\015' < $1 > ...
  46.  
  47. David W. Tamkin   Box 59297   Northtown Station, Illinois  60659-0297
  48. dattier@ddsw1.mcs.com    CompuServe: 73720,1570    MCI Mail: 426-1818
  49.