用 Shell 在 PDF 檔案中,找出指定字串

版主: stnet253

回覆文章
tony
文章: 585
註冊時間: 2012-02-26, 07:04
聯繫:

用 Shell 在 PDF 檔案中,找出指定字串

未閱讀文章 tony »

From: http://stackoverflow.com/questions/1444 ... with-shell

Find string inside pdf with shell

As nicely pointed by Simon, you can simply convert the pdf to plain text using pdftotext, and then, just search for what you’re looking for.

After conversion, you may use grep, bash regex, or any variation you want:

代碼: 選擇全部

while read line; do
 
    if [[ ${line} =~ [0-9]{4}(-[0-9]{2}){2} ]]; then
        echo ">>> Found date;";
    fi
 
done <<(pdftotext infile.pdf -)
回覆文章

誰在線上

正在瀏覽這個版面的使用者:Semrush [Bot] 和 1 位訪客