开发者

Folder Renaming After Tar Extraction

开发者 https://www.devze.com 2022-12-31 23:58 出处:网络
I have a tarball, myarchive.tar.gz. When I uncompress it using \"tar -zxvf myarchive.tar.gz\", it creates a folder myarchive-x980-2303-ssioo. What\'s the easiest way to automatically rename the extrac

I have a tarball, myarchive.tar.gz. When I uncompress it using "tar -zxvf myarchive.tar.gz", it creates a folder myarchive-x980-2303-ssioo. What's the easiest way to automatically rename the extracted folder to ensure it matches the name of the archive? I've checked tar's 开发者_高级运维manpage, but it doesn't seem to have an option for this.


Manually create folder, and strip components from tarball:

archive=my.tar.gz
mkdir ${archive%.tar*} 
tar --extract --file=${archive} --strip-components=1 --directory=${archive%.tar*}


mkdir pretty_name && tar xf ugly_name.tar -C pretty_name --strip-components 1

from https://unix.stackexchange.com/questions/11018/how-to-choose-directory-name-during-untarring

0

精彩评论

暂无评论...
验证码 换一张
取 消