| 1. |
Explain Trap Command; Shift Command, Getopts Command Of Linux |
|
Answer» Trap command: controls the action to be taken by the shell when a signal is received. SHIFT Command: USING shift command, command line arguments can be accessed. The command causes the positional parameters shift to the left. Shift [n] where n defaults to 1. It is USEFUL when several parameters NEED to be tested. Getopts command: this command is used to parse arguments passed. It EXAMINES the next command line argument and determines whether it is a valid option. Getopts {optstring} {variable1}. Here, optsring contains letters to be recognized if a letter is followed by a colon, an argument should be specified. E.g (whether the argument begins with a minus sign and is followed by any single letter contained inside options ) If not, diagnostic messages are shown. It is usually executed inside a loop. Trap command: controls the action to be taken by the shell when a signal is received. Shift Command: Using shift command, command line arguments can be accessed. The command causes the positional parameters shift to the left. Shift [n] where n defaults to 1. It is useful when several parameters need to be tested. Getopts command: this command is used to parse arguments passed. It examines the next command line argument and determines whether it is a valid option. Getopts {optstring} {variable1}. Here, optsring contains letters to be recognized if a letter is followed by a colon, an argument should be specified. E.g (whether the argument begins with a minus sign and is followed by any single letter contained inside options ) If not, diagnostic messages are shown. It is usually executed inside a loop. |
|