You should use the =
operator for string comparison:
Sourcesystem="ABC"
if [ "$Sourcesystem" = "XYZ" ]; then
echo "Sourcesystem Matched"
else
echo "Sourcesystem is NOT Matched $Sourcesystem"
fi;
man test
says that you use -z
to match for empty strings.
More Related Contents:
- How to read a file into a variable in shell?
- What does the line “#!/bin/sh” mean in a UNIX shell script?
- Difference between sh and Bash
- Pass commands as input to another command (su, ssh, sh, etc)
- How to select lines between two marker patterns which may occur multiple times with awk/sed
- “ls: not found” after running “read PATH”
- How to use multiple arguments for awk with a shebang (i.e. #!)?
- What are the uses of the exec command in shell scripts? [closed]
- How can I reverse the order of lines in a file?
- What does $@ mean in a shell script?
- How to make grep only match if the entire line matches?
- How can I execute a command stored in a variable?
- Compare two files line by line and generate the difference in another file
- Alternative to `sed -i` on Solaris
- Floating-point arithmetic in UNIX shell script
- How do you tell if a string contains another string in POSIX sh?
- Concise and portable “join” on the Unix command-line
- How do I get the effect and usefulness of “set -e” inside a shell function?
- How can I redirect the output of the “time” command?
- Shell one liner to prepend to a file
- How is % (percent sign) special in crontab?
- Trim leading and trailing spaces from a string in awk
- Can I call a function of a shell script from another shell script?
- What’s the difference between ${varname} and $varname in a shell scripts
- What’s the point of eval/bash -c as opposed to just evaluating a variable?
- Read file into String and do a loop in Expect Script
- Which terminal command to get just IP address and nothing else?
- How to add text at the end of each line in unix
- How to print 5 consecutive lines after a pattern in file using awk [duplicate]
- Unix shell script find out which directory the script file resides?