SHELL Script Example: parse command line input using shell script
SHELL Script Example: how to parse command line input using shell script?
getopts receive argument(s) from command line for shell.
create a file named "shell-script-example-parse-command-line-input.sh" then copy and paste the below code:
#!/bin/bash
while getopts p:abcd input
do
case $input in
a) echo "You press a";
b) echo "You press b";
c) echo "You press c";
d) echo "You press d";
esac
done
SHELL Script Example: parse command line input using shell script?
Now run the program (shell-script-example-parse-command-line-input.sh) from shell command prompt with some argument(s) & get the desired result as follows:
SHELL Script Example: parse command line input using shell script - output in the shell command prompt
Related Tutorial Examples
- Arithmetic Operations in SHELL Script Example
- Unix wc-l Equivalent DOS Command Using C Program
- AWK SHELL Script File Last Modification Information Changing Delimiter
- UNIX Command Example: head - Read beginning of a file
- UNIX Command Example: grep - Searching word or string in file or content
- UNIX Command Example: cat - Read file(s)
- UNIX Command Example: chgrp - Change group ownership
- 20 Steps to Make CakePHP Blog Project
- 19 Examples to Learn MySQL
- 28 Tutorials to Learn Oracle

No comments:
Post a Comment
leave your comments here..