xjx424 Posted April 12, 2011 Share Posted April 12, 2011 Hi, I am trying to zip a directory but when I zip and unzip it, it contains the whole path of the variable "album". I would just like to zip the last folder in the path. Here is what I have now. I tried basename but that didn't seem to work, possible I just can't make it work right. #!/bin/shalbum=/var/www/hfandt.com/artists/*/*for al in $albumdo if [ ! -f "$al" ]; then tar -zcvf "$al.tar.gz" "$al" rm -r "$al" fidone Thanks Link to comment Share on other sites More sharing options...
shadowayex Posted April 13, 2011 Share Posted April 13, 2011 What do you mean by "it"? Does the compressed file contain all of that, or the file name, or what? Link to comment Share on other sites More sharing options...
xjx424 Posted April 13, 2011 Author Share Posted April 13, 2011 When I untar the file I get the folder var. Then I open that and get every folder in the path. The folder being tar'ed is the var folder, not the target folder at the end of the path.I tried using basename like so tar -zcvf "$al".tar.gz "$(basename "$al")" but the path is wrongI'm assuming it's the absolute path that is the problem, I don't know how to get around that Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.