Bash script to skip extraction of password protected archives

帅比萌擦擦* 提交于 2019-12-06 00:31:30

For zip files, you can specify a dummy (wrong) password with the -P flag. For non-encrypted files it will be ignored, for encrypted files you will get a warning and the file will be skipped. For example:

unzip -P x -o "$zip_path" -d "$destination_folder"

For tar files, encryption is not a standard feature, so I'm not sure you what you mean. You could try to redirect stdin to the script from /dev/null to make it fail to read and skip over to the next file:

tar -xvzf "$tgz_path" --directory "$destination_folder" < /dev/null

If this doesn't work, then you can try expect.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!