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:
Paturi Radhe Sravan 2019-11-11 21:49:37 +05:30 committed by maibin
parent 5ab8036f77
commit 6a41bd4bff
4 changed files with 37 additions and 0 deletions

View File

@ -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";

View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "Username: $1";
echo "Age: $2";
echo "Full Name: $3";

View File

@ -0,0 +1,8 @@
#!/bin/bash
i=1;
for user in "$@"
do
echo "Username - $i: $user";
i=$((i + 1));
done

View File

@ -0,0 +1,10 @@
#!/bin/bash
i=1;
j=$#;
while [ $i -le $j ]
do
echo "Username - $i: $1";
i=$((i + 1));
shift 1;
done