I have a script I am working on that reads off of a text file and will use the information stored in the text file to put each line entered in as an array. This array is a reference to files that are imported to a directory in another script. The problem is I built a function to zip the contents of the directory and change it's ownerships, but when I run the script it was zipping and attempting to change ownerships of the pwd. Here is my code below:
file=~/exporttool/zipFiles.txt index=0 declare -a studyinstanceuids while read line ; do studyinstanceuids[$index]="$line" index=$((index+1)) echo $line done < $file for i in "${studyinstanceuids[@]}" do echo "$i" | ./cmd2; done echo "Exams are in!"; ##Function with argument that will take prompt to change ownerships echo "What is the name of the owner: " read $owner zipForOwner(){ arg1=$1 for i in "${studyinstanceuids[@]}"; do zip -r ~/export/"${studyinstanceuids[@]}"/20140620_"${studyinstanceuids[@]}".zip . sudo chown $1:$1 ~/export/"${studyinstanceuids[@]}"/"${studyinstanceuids[@]}".zip sudo mv ~/export/"${studyinstanceuids[@]}"/"${studyinstanceuids[@]}".zip ~/home/"$1" done } zipForOwner $owner exit; Does anyone have any suggestions?