Trying to test for both upper and lower case directories
I am trying to get a script to print out whether a directory is lowercase uppercase or both. This is what I've got so far:
Now this will let me know whether either an upper or lowercase directory is present for the servername and also if both are present, like this
/tmp/server -lowercase present
/tmp/SERVER - uppercase present.
if both are present, it prints both
However, if I type in a lowercase name and there is only a lowercase directory, it still prints "both." What am I doing wrong? I think "[a-zA-Z]* is bad because it matches incorrectly. I think I need something like "[[:upper:]]*$ && [[lower:]]" but this does not work.
Any help would be greatly appreciated!
Moderator's Comments:
Please use code tags when posting data and code samples!
Last edited by vgersh99; 12-13-2012 at 09:53 PM..
Reason: code tags, please!
I think why what I have is not working is because the input that the user enters will only be uppercase or lowercase not both. So when my script checks the directories, it says yes there is uppercase when you enter the uppercase input and yes there is lowercase when you enter the lowercase input.
But then since the user does not enter both upper and lowercase input, the script will never say both. Is there an easy way to get the script to convert the input into uppercase while also checking for the lowercase name? Or am I off track here? Any help is appreciated. Also, thanks for your previous responses.
This script is what I have. It does identify both lower and upper case but will never print "both." For example, if I enter david as the input it responds david -lowercase. If I enter DAVID as the input it responds DAVID- uppercase. But if I type either david or DAVID it never prints both. But in reality there are both DAVID and david directories in /tmp such as this:
/tmp/david
/tmp/DAVID
I realize this may be a dumb question on my part, but it appears to me that the reason this script does not return the "both" value is that I am entering only lowercase or uppercase into the input and it is being read as such and not looking to see if there are the two directories.
Thanks again for your patience with my newbie questions!
Last edited by Corona688; 12-14-2012 at 12:56 PM..
You do realize you don't have to jam it all on one line? You can put a newline wherever you have a ; and immediately after pipes too.
I suggest trying my code from earlier, with some slight changes now that it's clearer what you want:
How it works: Take a name like 'abc9DEF' and strip all non A-Z from it, so you get abcDEF.
Then check for an uppercase letter followed by a lowercase one, or vice versa. If you find that, it's mixed case. Otherwise, it's either all-upper or all-lower.
Last edited by Corona688; 12-14-2012 at 01:04 PM..
Hi all,
I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like
. ; : ! ?I found the following command
sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
There is a script where we pass the parameter in lower case:
say: . ./scriptName pArameter
#!/bin/ksh
echo "`date` Entering $0 Reloading the $1 table "
mname1=$1
(code to login MYSQL Database)
Truncate table $mname1;
exit
!
Since now there is a limitaion of MYSQL that it accept... (5 Replies)
Hello Unix Gurus :
It would be really appreciative if can find a solution for this .
I have records in a file .
I need to Capitalize the records based on condition .
For Example i tried the following Command
COMMAND -->
fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Is there a command that can switch a character variable from UPPER case to lower case?
like
foreach AC ( ABC BCD PLL QIO)
set ac `COMMAND($AC)`
...
end
Thanks a lot! (3 Replies)
Hi all,
i have a data array as followes.
ARRAY=DFSG345GGG
ARRAY=234FDFG090
ARRAY=VDFVGBGHH
so on..........
i need all english letters to be change to lower case. So i am expecting to see
ARRAY=dfsg345ggg
ARRAY=234fdfg090
ARRAY=vdfvgbghh
so on........
If i have to copy this data in... (8 Replies)
Hi All
I have a script which extracts values from a Database (A persons name) and puts it into a variable in my script IE: $NAME
However the Value in the DB is all in uppercase and contains the users first name and last name
EG:
> echo $NAME
GRAHAM BOYLE
>
What I need is only the... (7 Replies)
I have a package to install and the installation script which does it . The files/directories names in the script are all lower case but the actual package has everything in upper case - file names, directories . I don't want to rename directories and files in the package - it has a lot of them . ... (2 Replies)
Hi, I have a variable $Ctrcd which contains country names in upper case and i want to convert them into lower case. I have tried so many solutions from already existing threads but couldn't get the correct one.
Can anybody help me with this.....
Thanks a lot.. (2 Replies)