home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!nucsrl!ddsw1!dattier
- From: dattier@ddsw1.mcs.com (David W. Tamkin)
- Subject: Re: need script to rename uppercase filenames
- Message-ID: <1992Sep8.022910.4634@ddsw1.mcs.com>
- Keywords: script,tar,msdos
- Organization: Contributor Account at ddsw1, Chicago, Illinois 60657
- References: <699@svcs1.UUCP> <1992Sep3.135042.29363@walter.bellcore.com>
- Date: Tue, 8 Sep 1992 02:29:10 GMT
- X-Disclaimer: Material posted in this article is the sole responsibility of
- the poster and does not represent MCSNet or the system owners.
- Lines: 38
-
- snk@bae.bellcore.com (Sam Kamens) wrote in
- <1992Sep3.135042.29363@walter.bellcore.com>:
-
- | #!/bin/ksh
- | # Script to rename a list of files to its lowercase equivalent while
- | # stripping extra carriage returns
- | #
- |
- | USAGE: $0 FILE1 FILE2 FILE3 ...
- |
- | for i in $*
- | do
- | lowfile=`echo $i | tr [A-Z] [a-z]`
- |
- | cat ${i} | tr -d '\015' > ${lowfile}
- | # you could do rm $i here if you want
- | done
-
- There's nothing in there that requires ksh rather than sh, but since
- you're using ksh anyway, how about
-
- typeset -l lowfile
- for i
- do lowfile=$i
- tr -d '\015' < $i > $lowfile
- done
-
- | You could also do this with a one-liner:
- |
- | cat $1 | tr -d '\015' > `echo $1 | tr [A-Z] [a-z]`
-
- That's the third time in this thread I've seen a suggestion to cat one file
- to a pipe. It's better to save a process and
-
- tr -d '\015' < $1 > ...
-
- David W. Tamkin Box 59297 Northtown Station, Illinois 60659-0297
- dattier@ddsw1.mcs.com CompuServe: 73720,1570 MCI Mail: 426-1818
-