I want to pass four parameters to bash script. script should copy files in user home directory.
/opt/script.sh f1 f2 f3 f4
FYI: 1-each file might be exist or not, might be one of them exist or four of them. 2- every time run script might call all or one of them like this:
/opt/script.sh f1 /opt/script.sh f1 f4
Here is my script, it always copy f1 and seems only one of them [if] execute!
#!/bin/bash for var in "$@" ; do T1=$1 T2=$2 if [ $T1 = "f1" ]; then cp file1 /home/users else if [ $T2 = "f2" ]; then cp file2 /home/users .... fi fi done