如何使用 grep 从 Android 历史文件中仅检索 http?

How to use grep to retrieve only http from Android History file?

我在仅从 com.android.chrome/app_chrome/Default/History 抓取 HTTP 链接时遇到了一些困难。我以为它会像 cat History | grep "HTTP" 一样简单,但它并没有 return 我什么。

历史文件的输出:

�����3https://github.com/GitHub: Where the world builds software · GitHub/�O�EL�<   �79   https://www.google.com/search?q=github&oq=github&aqs=chrome..69i57j0j0i131i433j0j5.3913j0j4&client=ms-android-samsung&sourceid=chrome-mobile&ie=UTF-8github - Google Search/�Oe9Xj    A�
                                                                                              https://whosebug.com/Stack Overflow - Where Developers Learn, Share, & Build Careers/�LJ[�L  �IG   https://www.google.com/search?q=Whosebug&oq=stackover&aqs=chrome.0.0i433i457j69i57j0l3.2897j0j9&client=ms-android-samsung&sourceid=chrome-mobile&ie=UTF-8Whosebug - Google Search/�Kפv�>    �9;   https://www.google.com/search?q=youtube&oq=youtu&aqs=chrome.0.69i59j69i57j0j0i433j5.3588j0j9&client=ms-android-samsung&sourceid=chrome-mobile&ie=UTF-8youtube - Google Search/�K�RU�  �https://www.google.com/search?client=ms-android-samsung&ei=LvySX7qWDbmortoPiMO3-A0&q=youtubeyoutube - Google Search/�� Ir�F    �I;   https://www.google.com/search?q=youtube&oq=youtu&aqs=chrome.0.0i131i433i457j69i57j0j0i433j5.1418j0j4&client=ms-android-samsung&sourceid=chrome-mobile&ie=UTF-8youtube - Google Search/���r��

    i�'   https://xsite.singaporetech.edu.sg/d2l/loginh/xSiTe - Learning Management System (LMS) of Singapore Institute of Technology/��]!��
        e�'   https://xsite.singaporetech.edu.sg/d2l/loginxSiTe - Learning Management System (LMS) of Singapore Institute of Technology/��m
�       S�'   https://xsite.singaporetech.edu.sg/xSiTe - Learning Management System (LMS) of Singapore Institute of Technology/��m
;!-   https://www.google.com/Google/�ؠ�,
                                       9      http://www.google.com/Google/��̗��1   �https://www.google.com.sg/search?q=xsite&oq=xsite&aqs=chrome..69i57j0l3.2094j0j7&client=ms-android-samsung&sourceid=chrome-mobile&ie=UTF-8xsite - Google Search/��\�h  E�    https://www25.gogoanimes.tv/KissAnime - Watch anime online in high quality at GoGoAnime/���8J�=   �https://www.google.com.sg/search?q=gogoanime&oq=gogoanime&aqs=chrome..69i57j0l3.2872j0j4&client=ms-android-samsung&sourceid=chrome-mobile&ie=UTF-8gogoanime - Google Search/����x  W�    https://www.starhub.com/personal.htmlPersonal Mobile Phones, Broadband, TV, Voice and Rewards | StarHub/���`k =�    https://www.starhub.com/Personal Mobile Phones, Broadband, TV, Voice and Rewards | StarHub/���`j  ;�    http://www.starhub.com/Personal Mobile Phones, Broadband, TV, Voice and Rewards | StarHub/���`(
                                                         1         http://google.com/Google/��̗�w   U�    http://www.starhub.com/personal.htmlPersonal Mobile Phones, Broadband, TV, Voice and Rewards d�����iQ9!���`  �����i

我们指示 grep 将二进制文件视为文本文件,并提取所有以 http(s) 开头且仅包含字母数字字符和标点符号的匹配字符串 - 我认为这应该为您提供所有链接目前。

grep --binary-files=text -Eo 'https*://[[:alnum:][:punct:]]+' History