The ==
operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?
相关问题
- How to get the return code of a shell script in lu
- how to split a list into a given number of sub-lis
- Generate string from integer with arbitrary base i
- Converting a string array to a byte array
- Invoking Mirth Connect CLI with Powershell script
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- JSP String formatting Truncate
- In IntelliJ IDEA, how can I create a key binding t
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Selecting only the first few characters in a strin
- Python: print in two columns
- Launch interactive SSH bash session from PHP
In Bash, you can use parameter expansion to modify a string to all lower-/upper-case:
For korn shell, I use typeset built-in command (-l for lower-case and -u for upper-case).
Here is my solution using tr:
One way would be to convert both strings to upper or lower:
Another way would be to use grep:
if you have bash
otherwise, you should tell us what shell you are using.
alternative, using awk
grep
has a-i
flag which means case insensitive so ask it to tell you if var2 is in var1.