ubuntu extract from all zip archives only files by regex in directory by path

To extract files from all zip archives in a specific directory by a regular expression, you can use a combination of the 

find and unzip commands in ubuntu terminal

bash
find /path/to/directory -maxdepth 1 -type f -name '*.zip' -exec unzip {} "your_regex_pattern" -d /path/to/destination_directory \; 

Explanation of the command:
find /path/to/directory: This starts the search for files in your specified directory.-maxdepth 1: This limits the search to only the specified directory and prevents it from searching subdirectories.
-type f: This ensures that only files (not directories) are selected.
-name '*.zip': This filters for files that have the .zip extension.
quotes around '*.zip' prevent from expanding the wildcard before find is run.
-exec unzip {} "your_regex_pattern" -d /path/to/destination_directory \;
-exec: This executes the following command for each found file.
unzip {}: This runs the unzip command on the found zip file, represented by {}."your_regex_pattern": This is the pattern for the files you want to extract from within the zip archive. must use wildcards here, not a full regex expression. For example, use '*file*.txt' to match file names containing "file" and ending with ".txt". The quotes prevent the shell from expanding the wildcard.
-d /path/to/destination_directory: This specifies the directory where the matching files will be extracted. Ensure you have write permissions to this directory.\;:
This terminates the -exec command, escaped so the passes it to find. 

Example:
To extract all files with a .log extension from all zip archives in /home/user/downloads and place them into /home/user/extracted_logs, the command would be:

bash
find /home/user/downloads -maxdepth 1 -type f -name '*.zip' -exec unzip {} '*.log' -d /home/user/extracted_logs \;

