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 Jeff Schaller for Unzip archive with single file and rename output to match archive name

$
0
0

You could continue with the -d idea, and simply rename any extracted file to the desired "zip name minus the zip plus txt":

mkdir tmpfor f in *.zip; do unzip "$f" -d tmp && mv tmp/* "${f%.zip}.txt"; donermdir tmp

Alternatively, you could pipe the output from unzip into the appropriately-named file:

for f in *.zip; do unzip -p "$f"> "${f%.zip}.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>