The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Lowercase to Uppercase ggovotsis AIX 7 10-16-2008 10:07 AM
Need to change filenames in a particular directory from lowercase to UPPERCASE Duke_Lukem UNIX for Dummies Questions & Answers 7 01-07-2008 06:32 PM
after i convert upper case to lowercase Alex20 Shell Programming and Scripting 1 03-07-2005 04:07 PM
Converting to Uppercase dreams5617 Shell Programming and Scripting 3 11-12-2004 01:44 AM
uppercase to lowercase webex Shell Programming and Scripting 4 01-03-2002 02:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-04-2005
Alex20 Alex20 is offline
Banned
  
 

Join Date: Mar 2005
Posts: 3
How convert lowercase or uppercase

It will only accept one argument where it should be upper or lowercase. if user choose to convert filnames to upper case than it should convert to upper or vice versa. if no action taken by the user then should not do anything


any of the files in the current directory.
  #2 (permalink)  
Old 03-04-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
Originally Posted by Alex20
It will only accept one argument where it should be upper or lowercase. if user choose to convert filnames to upper case than it should convert to upper or vice versa. if no action taken by the user then should not do anything


any of the files in the current directory.
pls post what you've got and where you're having problems.
  #3 (permalink)  
Old 03-04-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
Code:

if test $# -ne 1
then
   echo "wrong number of args: $0 flags[-l][-u] "
   return
fi

if test $1 = "-l"
then
    tr "[A-Z]" "[a-z]" < file1
elif test $1 = "-u"
then
    tr "[a-z]" "[A-Z]" < file1
else
    echo "wrong options: [-l][-u]"
fi
  #4 (permalink)  
Old 03-05-2005
muthukumar muthukumar is offline
Registered User
  
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
Use this script to change case name of all files in the current directory as,

Code:
#!/bin/sh
# Muthukumar
# Script to change name from upper to lower / lower to upper
# <usage> [lower | upper]

if [[ $# -ne 1 ]]
then
  echo "Usage: $0 [lower|upper]"
  exit 1
fi

for file in `find . -type f`
do
  if [[ "$1" = "lower" ]]
  then
    mv $file $(echo $file | tr [[:upper:]] [[:lower:]])
  elif [[ "$1" = "upper" ]]
  then
    mv $file $(echo $file | tr [[:lower:]] [[:upper:]])
  else
    echo "Unknown option $1. Use upper | lower"
    exit 1
  fi
done

exit 0
## END ##
HTH.
  #5 (permalink)  
Old 03-05-2005
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
If you want to ensure arguments past into your program are in the correct case, you should use typeset -u to convert to uppercase and typeset -l to convert to all lowercase.
  #6 (permalink)  
Old 03-07-2005
Alex20 Alex20 is offline
Banned
  
 

Join Date: Mar 2005
Posts: 3
hello i need your help
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0