I hope either one below will do your work,
option 1:
create a file with the list of 16 directories as below,
$cat DirList.txt
/artifactserver/com/xyz/abc/App1/target/
/artifactserver/com/xyz/abc/App2/target/
/artifactserver/com/xyz/abc/App3/target/
...
/artifactserver/com/xyz/abc/App16/target/
use the this file as input to while loop below,
i=1 // **i** - incremental variable
while read dirName
do
cd ${dirName} # --> change directory
tar -cvf App${i}Home.tar App${i}Home/ # --> tar directory
cp App${i}Home.tar /tmp # --> copy tar file to /tmp
i=$(expr $i + 1) # --> increase variable i by one.
done < DirList.txt
option 2:
create a file with the list of 16 directories, tar filename and directory name to be tarred with a delimiter, here i used |
as the delimiter
$cat DirList.txt
/artifactserver/com/xyz/abc/App1/target/|App1Home.tar|App1Home
/artifactserver/com/xyz/abc/App2/target/|App2Home.tar|App2Home
/artifactserver/com/xyz/abc/App3/target/|App3Home.tar|App3Home
...
/artifactserver/com/xyz/abc/App16/target/|App16Home.tar|App16Home
use the this file as input to while loop below,
while read line
do
dirName=$(echo $line | awk -F'|' '{print $1}') # --> assign first var to directory
tarFile=$(echo $line | awk -F'|' '{print $2}') # --> tar file name
dirToTar=$(echo $line | awk -F'|' '{print $3}') # --> directory name to be tarred
cd ${dirName} # --> change directory
tar -cvf ${tarFile} ${dirToTar} # --> tar directory
cp ${tarFile} /tmp # --> copy tar file to /tmp
done < DirList.txt