Linux shell programming string compare syntax
问题 What is the difference between = and == to compare strings in Linux shell programming? Maybe the following code works: if [ "$NAME" = "user" ] then echo "your name is user" fi But I think it's not a correct syntax. It would be used to compare string by == statement. What is correct? 回答1: These pages explain the various comparison operators in bash: http://www.tech-recipes.com/rx/209/bournebash-shell-scripts-string-comparison/ http://tldp.org/LDP/abs/html/comparison-ops.html http://www.faqs