To tar the content while copying files

Any idea on how we can tar the content while copying the files from one location to another location using the bash script.

If you want to store tar contents of directory ./XYZ and all files/directores under it to /path/to/dest/XYZ.tar use:

tar cf /path/to/dest/XYZ.tar  ./XYZ

Example contents of /path/to/dest/XYZ.tar tarfile might be:

./XYZ/.profile
./XYZ/.kshrc
./XYZ/save.ksh
./XYZ/ZZZ
./XYZ/ZZZ/testing.c
./XYZ/ZZZ/testing.o

Thanks...