简体   繁体   中英

Unzip only files that start with a certain word

I have a zip archive (let's call it archive) and let's say I want to go through some directories and finally extract ONLY the files that start with the word 'word'. Some thing similar to:

archive.zip/dir1/dir2/word***.csv

What is the command that could do this without having to extract the whole file (very big file)?

I tried this command line:

unzip -p archive.zip dir1/dir2/word***1.csv >destination

But this only extracts one file not all files that start with 'word'

You should do

unzip -p archive.zip dir1/dir2/word*1.csv >>destination.csv

The > truncates file destination.csv to zero length giving you the impression that only one file was unzipped, while >> creates the file if not present, otherwise appends to it which is the required behavior.

Reference : Check I/O redirection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM