Lowercase -> Uppercase and vice-versa

Lowercase -> Uppercase and vice-versa

Post by Noah Friedm » Thu, 11 Feb 1993 15:02:25




>Here's a little script I wrote to handle such things.

>for file in $*
>do
>  mv -f $file `echo $file | tr '[A-Z]' '[a-z]'` 2>/dev/null 1>&2
>done

>swap the [A-Z] and [a-z] for uppercase/lowercase.

Now I feed your script (for example) the argument "/Foo/BAR/baz/File1.c"?

Lose.

How about:

    #!/bin/sh

        dirname="`echo ${file} | sed -e 's/\/[^\/]*$//'`"
        basename="`echo ${file} | sed -e 's/.*\/\([^\/]*\)$/\1/'`"
        new_basename="`echo ${basename} | tr '[A-Z]' '[a-z]'`"
        if test "z${basename}" = "z${file}" ; then
           newname="${new_basename}"
        else
           newname="${dirname}/${new_basename}"
        fi
        if test "z${newname}" = "z${file}" ; then
           :
        else
           echo mv "${file}" "${newname}"
        fi
    done

This is as portable a shell script as you're ever going to see, and it
handle arbitrary filenames correctly, including weird ones with spaces,
etc. in them.

 
 
 

Lowercase -> Uppercase and vice-versa

Post by Bryan You » Thu, 11 Feb 1993 02:39:57


Here's a little script I wrote to handle such things.

for file in $*
do
  mv -f $file `echo $file | tr '[A-Z]' '[a-z]'` 2>/dev/null 1>&2
done

swap the [A-Z] and [a-z] for uppercase/lowercase.

 
 
 

Lowercase -> Uppercase and vice-versa

Post by Noah Friedm » Thu, 11 Feb 1993 18:21:41



Quote:>           echo mv "${file}" "${newname}"

Argh!  And take out the `echo', too.

<bonk>

 
 
 

Lowercase -> Uppercase and vice-versa

Post by Noah Friedm » Thu, 11 Feb 1993 18:20:23



>This is as portable a shell script as you're ever going to see, and it
>handle arbitrary filenames correctly, including weird ones with spaces,
>etc. in them.

   Whoops, there's always one more bug.  The following should actually work
as advertised:

    #!/bin/sh

        dirname="`echo \"${file}\" | sed -e 's/\/[^\/]*$//'`"
        basename="`echo \"${file}\" | sed -e 's/.*\/\([^\/]*\)$/\1/'`"
        new_basename="`echo \"${basename}\" | tr '[A-Z]' '[a-z]'`"
        if test "z${basename}" = "z${file}" ; then
           newname="${new_basename}"
        else
           newname="${dirname}/${new_basename}"
        fi
        if test "z${newname}" = "z${file}" ; then
           :
        else
           echo mv "${file}" "${newname}"
        fi
    done

 
 
 

Lowercase -> Uppercase and vice-versa

Post by Christos Zoul » Sat, 13 Feb 1993 05:38:13



>How about:

>    #!/bin/sh

>        dirname="`echo ${file} | sed -e 's/\/[^\/]*$//'`"
>        basename="`echo ${file} | sed -e 's/.*\/\([^\/]*\)$/\1/'`"
>        new_basename="`echo ${basename} | tr '[A-Z]' '[a-z]'`"
>        if test "z${basename}" = "z${file}" ; then
>           newname="${new_basename}"
>        else
>           newname="${dirname}/${new_basename}"
>        fi
>        if test "z${newname}" = "z${file}" ; then
>           :
>        else
>           echo mv "${file}" "${newname}"
>        fi
>    done

>This is as portable a shell script as you're ever going to see, and it
>handle arbitrary filenames correctly, including weird ones with spaces,
>etc. in them.

It does not handle iso_8859_1 characters correctly...

in tcsh:

foreach file (*)
        if ("$file:h" != "$file") then
            set nfile="$file:h/$file:t:al"
        else
            set nfile="$file:al"
        endif
        mv "$file" "$nfile"
end

christos

 
 
 

1. Using Oracle to mirror NIS maps & vice-versa

   Has anyone ever used Oracle to "mirror" NIS maps, as well
as conversely?  I work at a company as UNIX programmer and systems
administrator in my group and we manage close to a thousand
workstations (Suns, SGIs, Solbournes) and a few dozen servers.
We also have 2 servers implemented as NIS masters (hence, two
different domains).  We would like to implement Oracle in
such a way that the database has tables which essentially
mirror the NIS maps (one table per map, say?).  The scheme is that
Whenever a change to a map occurs (via /var/yp/make map_name) the
corresponding table in Oracle gets changed as well.  A more
difficult scheme would be to do the reverse (update the database
table and the corresponding NIS map would automatically be
updated), but my main concern is getting the former implemented
first.  
   Has anyone ever done this before?  How feasible is it?  What
should I be concerned with in such a scheme?  BTW, we also plan
to create tables which do not have corresp. NIS maps but will
be used to hold other useful info.  The purpose for thsi whole
scheme is to enable users and administrators to tap into the
Oracle database as a global source of information on our workstations
(as well as PCs ... soon), as well as users of thos workstations,
instead of relying on several different sources for the information
(e.g. WingZ spreadsheets, FrameMaker documents, files out in UNIX,
as well as NIS maps).  One could easily tap into the database via
shell scripts or a variety of programming languages.

    Any opinions or help on this matter is greatly appreciated!

                                --John

2. Linux wont boot anymore!

3. SOS: C Routines for ASCII to EBCDIC Conversion and Vice-versa

4. linuxconf's network time servers?

5. VMware: Windows on Linux or vice-versa?

6. LDAP Issues

7. How to quickly take an Ultra-1 off the net to be standalone and vice-versa???

8. Threaded Web Server

9. how to backup files from solaris 8 to linux rh 6.0 or vice-versa at SOHO.

10. converting netscape bookmarks to kfm and vice-versa

11. mounting one partition to two directories and vice-versa

12. "gd" gif library doesn't like the Apache server (or vice-versa)

13. Why sendmail over smail or vice-versa ?