Quantcast
Channel: Unzip archive with single file and rename output to match archive name - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by αғsнιη for Unzip archive with single file and rename output to match archive name

$
0
0

The command unzip has its own option unzip -Z1 zipfile.zip to show the actual compressed filename within zipped file which is taking zipinfo's option -1 as it's zipinfo -1 zipfile.zip. so you could simply do as below and there is no need to create a temp directory and mv will done in place in current directory.

for z in *.zip; do     unzip "$z";    mv "$(unzip -Z1 $z)""${z%%.*}.txt";done

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>