#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    65
    Rep Power
    0

    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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    121
    Rep Power
    11
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    65
    Rep Power
    0
    Thanks grep worked!

IMN logo majestic logo threadwatch logo seochat tools logo