Learning Linux Shell Scripting by Ganesh Sanjiv Naik

Learning Linux Shell Scripting by Ganesh Sanjiv Naik

Author:Ganesh Sanjiv Naik
Language: eng
Format: epub
Publisher: Packt Publishing


Since the user Ganesh is already created on the computer, the string Ganesh was found in the /etc/passwd file.

$ name=John $ grep "$name" /etc/passwd $ echo $? 1 # non zero values means error

Since the user John was not found in the /etc/passwd file, the grep command returned a nonzero value. In scripts, we can use this during automation.

Understanding the test command

Let's now understand the test command.

Using the test command with single brackets

Let's learn the following example to check the content or value of expressions:

$ test $name = Ganesh $ echo $? 0 if success and 1 if failure.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.