I am using this command
tar -zcf acc.tar.gz /home/uname/public_html/project/js
it is creating the zip file fine, but zip file contains all the folders in home->uname->public_html->projects/js..
i want only js folder in the zip
..
Try the following to get only the contents
of the js folder
, and no sub-directory content:
tar -czf acc.tar.gz --no-recursion /home/uname/public_html/project/js/*
Try the following to change to the directory to avoid archiving the absolute path:
tar -czf acc.tar.gz -C /home/uname/public_html/project ./js
From the man tar
page:
--no-recursion
don't recurse into directories
-C, --directory DIR
change to directory DIR