Help for this page

Select Code to Download


  1. or download this
      I have a list of company names all in upper case; one per line.
      Can I use a combination of sed, tr, and other tools to automate
      converting them all to mixed case (i.e., initial letter uppercase,
      all others lower case)? There must be a shell script already
      written to do this, but not in the reference books I have.
    
  2. or download this
       perl -ne 'print ucfirst lc;' FILENAME
       will do it.
    
  3. or download this
       perl -pe 'tr/A-Z/a-z/; s/(\S+)/\u$1/g;' <filename>
    
  4. or download this
       My sed-fu was deficient I guess (or my sed was) so I fell back to p
    +erl:
    
    ...
       perl -pe 's/ \b (\w) ([^\s]+) \b /\1\L\2/gx'
    
       # ONE COMPANY  -> One Company (rather than One company)
    
  5. or download this
       perl -i -ne 's/(\b\w)/{uc $1}/eg; print;' <FILENAME>