I'm trying to finish a little bash project and I got stuck while trying to tar a folder given a path. For example, the program receives the route
/home/folderx. Then, it looks for every folder inside that directory with a
for i in ~/folderx/*; do... loop. And here's the problem: I'm trying to tar every folder inside that route with
tar -czvf $i.tgz $i -P, but it compress the entire route that was given to the program. At the end, I obtain a
.tgz with the correct name (the name of the directory that I wanted to tar) but inside it there's
/home/folderx/name_of_the_folder/contents instead of just
What's the problem? Thank you very much.