BAEL-3469 - How to pass command line arguments to Bash Script (#8174)
* Example for hexagonal architecture in java * BAEL-3469 - How to Pass command line arguments to bash script * Removed source code for evaluation article
This commit is contained in:
parent
5ab8036f77
commit
6a41bd4bff
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while getopts u:a:f: flag
|
||||||
|
do
|
||||||
|
case "${flag}"
|
||||||
|
in
|
||||||
|
u) username=${OPTARG};;
|
||||||
|
a) age=${OPTARG};;
|
||||||
|
f) fullname=${OPTARG};;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "Username: $username";
|
||||||
|
echo "Age: $age";
|
||||||
|
echo "Full Name: $fullname";
|
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Username: $1";
|
||||||
|
echo "Age: $2";
|
||||||
|
echo "Full Name: $3";
|
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
i=1;
|
||||||
|
for user in "$@"
|
||||||
|
do
|
||||||
|
echo "Username - $i: $user";
|
||||||
|
i=$((i + 1));
|
||||||
|
done
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
i=1;
|
||||||
|
j=$#;
|
||||||
|
while [ $i -le $j ]
|
||||||
|
do
|
||||||
|
echo "Username - $i: $1";
|
||||||
|
i=$((i + 1));
|
||||||
|
shift 1;
|
||||||
|
done
|
Loading…
x
Reference in New Issue
Block a user