InterviewSolution
Saved Bookmarks
| 1. |
Name the command that is used to compare the strings in a shell script. |
|
Answer» To compare text strings, use the test command. By COMPARING each character in each STRING, the test command usually COMPARES text strings. In most cases, tests are generally included as a conditional execution of shell commands. It can be used for:
Using square brackets ([ and ]) around the EXPRESSION is equivalent to testing it with the test. Syntax of test command:
Examples:
Because 50 is greater than 40, this command prints the text "Yes".
As the two strings are identical, this command prints "0" because the expression is true. |
|