Patch-ID: bash40-021
[bash.git] / examples / functions / lowercase
blob3cf6bde2f8433fc5824fecd3c72aa427fcba4729
1 #! /bin/bash
3 # original from
4 # @(#) lowercase.ksh 1.0 92/10/08
5 # 92/10/08 john h. dubois iii (john@armory.com)
7 # conversion to bash v2 syntax done by Chet Ramey
9 lowercase()
11 for file; do
12 [ -f "$file" ] || continue
13 filename=${file##*/}
14 case "$file" in
15 */*) dirname=${file%/*} ;;
16 *) dirname=.;;
17 esac
18 nf=$(echo $filename | tr A-Z a-z)
19 newname="${dirname}/${nf}"
20 if [ "$nf" != "$filename" ]; then
21 mv "$file" "$newname"
22 echo "lowercase: $file -> $newname"
23 else
24 echo "lowercase: $file not changed."
26 done