February 5th, 2004, 06:58 PM
need help with csh script
I am writing a script which is to search for some strings in a text file. When you execute the script like this "scriptname <argument>" it will output all the lines in the text file with the substring of the argument for example scriptname Bob will output all lines with Bob in them. I can do this easily enough with awk. The problem is, if you type scriptname bob, it will only match bob but not Bob. Unfortunately there is no way to ignore case with awk. How can I get around this? It is safe to assume that in the text file the substrings I search for will always start with a capital and be followed by lower case letters. So if there is a way to convert only the first letter of the argument to a capital, that would solve my problem. For example if the user types "scriptname bob" or "scriptname BOB" it should convert the argument bob or BOB to Bob. Is there a way I can convert only the first letter of the argument to a capital and convert the rest of the letters of that argument to lower case?
February 6th, 2004, 09:38 AM
That would not be easy in csh. You should consider switching to ksh or bash. They are much more powerful.
But I have another solution: use grep -i. With -i, grep will ignore case.
February 6th, 2004, 11:53 AM