Currently I'm executing my bash script with unnamed filename parameters:
./exec.sh filename1 filename2
What I want to achieve is to add one named parameter s
./exec.sh filename1 filename2 -s bla
where s
is an optional argument stands for "suffix" and if exists, has to be appended to all filenames inside script.
I have a part in bash script that looks like:
for param in "$@"
do
file_name=$(< $files/$param)
As far as I know, I should use getopt
but not sure about its syntax.
How can I implement to get optional -s
parameter from the arguments list?