mirror of
https://github.com/Hizenberg469/Makefile-tutorial.git
synced 2026-04-19 22:02:24 +03:00
created shell dir
This commit is contained in:
40
shell/getopt.sh
Normal file
40
shell/getopt.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "All arguments: $@"
|
||||
|
||||
opts=`getopt -o a::b:cde --long file::,name:,help -- "$@"`
|
||||
eval set -- "$opts"
|
||||
echo "All arguments after getopt: $@"
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-a) echo "parameter 'a' selected with argument: $2"
|
||||
shift 2 #same of 2 shift command
|
||||
;;
|
||||
-b) echo "parameter 'b' selected with argument: $2"
|
||||
shift 2
|
||||
;;
|
||||
-c) echo "paramter 'c' selected"
|
||||
shift
|
||||
;;
|
||||
-d) echo "paramter 'd' selected"
|
||||
shift
|
||||
;;
|
||||
-e) echo "paramter 'e' selected"
|
||||
shift
|
||||
;;
|
||||
--file) echo "parameter 'file' selected with argument: $2"
|
||||
shift 2
|
||||
;;
|
||||
--name) echo "parameter 'name' selected with argument: $2"
|
||||
shift 2
|
||||
;;
|
||||
--help) echo "parameter 'help' selected"
|
||||
shift
|
||||
;;
|
||||
*) echo "something else: $1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user