From the course: Linux System Engineer: Bash Shell Scripting for Automation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Process shell options

Process shell options

From the course: Linux System Engineer: Bash Shell Scripting for Automation

Start my 1-month free trial

Process shell options

- [Instructor] The last way that we will input information into our scripts and make them act more like Linux system commands, is by allowing command line options. For instance, with the ls command, we can type in ls, space, dash, l, and the dash l option modifies the ls command output. Be sure that you're in your tilde slash bin directory. Type in clear, and now create a script called getopts dot sh, by typing in vi, space, getopts dot sh, and hit Enter. Go into insert mode and add hash, bang, slash, bin, slash, bash. New line, while, space, getopts, space, double quote, colon, a, double quote, space, opt, semi colon, space, do. New line, case, space, dollar sign, opt, space, in. New line, a, right parentheses, space, echo, space, double quote, you passed the dash a option, double quote, space, greater than, and press and, two, space, semi colon, semi colon. New line, backslash, question mark, right parentheses, echo, space, double quote, invalid, space option, colon, space, dash…

Contents