1754340 Members
4837 Online
108813 Solutions
New Discussion юеВ

Shell script Problem

 
SOLVED
Go to solution
Ryan Ma
Frequent Advisor

Shell script Problem

I am writing a script "/match" to print out a line if two fileds in the input file match.input match.

For example:
# cat match.input
abc
abc
# /match
Match!

# cat match.input
abc
def
# /match
Not match!

# cat match.input
abc
ABC
# /match
Match!

The script should be non-case sensitive.
I have written a version with case-sensitive but I cannot write one with non-case sensitive.

I am using awk.

Thx.
2 REPLIES 2
Steven Sim Kok Leong
Honored Contributor
Solution

Re: Shell script Problem

Hi,

Set all to lowercase before comparison. Use awk's tolower(s) function.

tolower(s) Converts the argument string s to lowercase and returns the result.

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Tom Geudens
Honored Contributor

Re: Shell script Problem

Hi,
The "tr" command will solve that problem for
you. The example is even given in the
manpages.

Regards,
Tom Geudens
A life ? Cool ! Where can I download one of those from ?