给予:
通缉:
我该怎么做?目前,我有一个脚本,将搜索字符串在PDF文件,内部,拉链和打印出来的名字,zip和里面的pdf。我会把这封信寄给你:
#!/bin/bash
echo "Hi I'll find text in pdf files that are stored inside zip files."
echo ""
echo "Enter search string:"
read searchString
echo "Ok. I'll search all zip files for content with this text..."
for z in *.zip
do
zipinfo -1 "$z" | # Get the list of filenames in the zip file
while IFS= read -r f
do
unzip -p "$z" "$f" | # Extract each PDF to standard output instead of a file
pdftotext - - | # Then convert it to text, reading from stdin, writing to stdout
grep -q $searchString && echo "$z -> $f" # And finally grep the text
done
done 这个脚本是由于这个答案而创建的。
发布于 2019-12-11 09:48:59
从zip归档解压缩特定文件
unzip -j "myarchive.zip" "in/archive/file.pdf" -d "/destination/path/"在你的剧本里
# Set a destination path
dest="/path/to/unzip/to"
# dump pdf to temp text file
tempfile=$(mktemp)
# unzip the file to stdOut and convert it to text
unzip -p "$z" "$f" | pdftotext - $tempfile
if grep -q $searchString $tempfile; then
unzip -j "$z" "$f" -d "$dest"
# some text output
echo "$z -> $f"
fi
rm $tempfilehttps://askubuntu.com/questions/1195340
复制相似问题