Command Substitution•a string in back quotes ` … ` does command substitutionThis means that the result of the command (the standard–This means that the result of the command (the standard output of the command) replaces the back quoted string Examples:count=`wc -w <$1`# the value of count is assigned the number of words in file $1if [ `wc -l < $2.txt` -lt 1000 ];#checks if the number of lines in the file is < 1000cat `grep -l exit *.sh`#print out all * sh files containing the word exit2#print out all *.sh files containing the word exit
Exit Command (again)•Conventionally, zero normally indicates success. Nonzero values indicate some type of failureIt isNonzero values indicate some type of failure. It is thus good practice to ensure that if the shell script terminates properly, it is with an “exit 0” dcommand.•If the shell script terminates with some error that would be useful to a calling program terminatewould be useful to a calling program, terminate with an “exit 1” or other nonzero condition.•most Unix utilities that are written in C will also call “exit(<value>);” upon termination to pass a value back to the shell or utility that called that tilit3utility.
has intentionally blurred sections.
Sign up to view the full version.