2015-08-27 40 views
2

我想grep只在每個http:行之後的文本並將其寫入文件。 我從輸出流電流輸出如何從輸出grep並將greipe文本寫入fille

References 
 

 
    1. https://soundcloud.com/sc-opensearch.xml 
 
    2. https://m.soundcloud.com/search/sounds?q=L AME IMMORTELLE 
 
    3. https://soundcloud.com/ 
 
    4. http://www.enable-javascript.com/ 
 
    5. https://soundcloud.com/search 
 
    6. https://soundcloud.com/search/sounds 
 
    7. https://soundcloud.com/search/sets 
 
    8. https://soundcloud.com/search/people 
 
    9. https://soundcloud.com/search/groups 
 
    10. https://soundcloud.com/thomas-rainer/l-ame-immortelle-banish 
 
    11. https://soundcloud.com/outtamyndxmetal-llc/lame-immortelle-the-heart 
 
    12. https://soundcloud.com/cyberdelic-mind/l-me-immortelle-dark-mix-i 
 
    13. https://soundcloud.com/sawthinzarhtaik/dort-drauben 
 
    14. https://soundcloud.com/lagrima-negra/lagrima-tears-in-the-rain 
 
    15. https://soundcloud.com/bathony/in-strict-confidence-zauberschlos-lame-immortelle-version 
 
    16. https://soundcloud.com/jubej-thos/sirius-5-jahre-lame-immortelle 
 
    17. https://soundcloud.com/virul3nt/lamme-immortelle-sag-mir-wann-shiv-r-remix 
 
    18. https://soundcloud.com/outtamyndxmetal-llc/lame-immortelle-no-goodbye 
 
    19. https://soundcloud.com/usefulrage/das-ich-dem-ich-den-traum 
 
    20. http://help.soundcloud.com/customer/portal/articles/552882-the-site-won-t-load-for-me-all-i-see-is-the-soundcloud-logo-what-can-i-do- 
 
    21. http://google.com/chrome 
 
    22. http://firefox.com/ 
 
    23. http://apple.com/safari 
 
    24. http://windows.microsoft.com/ie 
 
    25. http://help.soundcloud.com/

,目前我的代碼是不是greping低於

lynx --dump -listonly https://soundcloud.com/search/sounds?q=L%20AME%20IMMORTELLE | \ 
tr "\t\r\n'" ' "' | \ 
grep -i -o 'http......HERE I NEED THE GREP STUFF' | \ 
sed -e 's/^.*"\([^"]\+\)".*$/\1/g' \ >k.txt 
+0

沒有任何空間之前// – bulldog68

+0

我想整個的http:///。 ..............鏈接 – bulldog68

回答

1

您可以使用grep -E

grep -i -oE 'https?://soundcloud\.com[^[:blank:]]*' 
+1

感謝兄弟的工作 – bulldog68

+1

你救了我,非常感謝:) – bulldog68

+0

兄弟如果我只想獲得以https://soundcloud.com/開頭的文本..........我的意思是我不想打印其他網站的鏈接,如何我們可以改變grep嗎? – bulldog68

0

I噸,

lynx --dump -listonly https://soundcloud.com/search/sounds?q=L%20AME%20IMMORTELLE | \ 
 
    tr "\t\r\n'" ' "' | \ 
 
    grep -i -oE 'https?://[^[:blank:]]+' | \ 
 
    sed -e 's/^.*"\([^"]\+\)".*$/\1/g' \ 
 
>k.txt

工作,我得到了適當的輸出

https://soundcloud.com/sc-opensearch.xml 
 
https://m.soundcloud.com/search/sounds?q=L 
 
https://soundcloud.com/ 
 
http://www.enable-javascript.com/ 
 
https://soundcloud.com/search 
 
https://soundcloud.com/search/sounds 
 
https://soundcloud.com/search/sets 
 
https://soundcloud.com/search/people 
 
https://soundcloud.com/search/groups 
 
https://soundcloud.com/thomas-rainer/l-ame-immortelle-banish 
 
https://soundcloud.com/outtamyndxmetal-llc/lame-immortelle-the-heart 
 
https://soundcloud.com/cyberdelic-mind/l-me-immortelle-dark-mix-i 
 
https://soundcloud.com/sawthinzarhtaik/dort-drauben 
 
https://soundcloud.com/lagrima-negra/lagrima-tears-in-the-rain 
 
https://soundcloud.com/bathony/in-strict-confidence-zauberschlos-lame-immortelle-version 
 
https://soundcloud.com/jubej-thos/sirius-5-jahre-lame-immortelle 
 
https://soundcloud.com/virul3nt/lamme-immortelle-sag-mir-wann-shiv-r-remix 
 
https://soundcloud.com/outtamyndxmetal-llc/lame-immortelle-no-goodbye 
 
https://soundcloud.com/usefulrage/das-ich-dem-ich-den-traum 
 
http://help.soundcloud.com/customer/portal/articles/552882-the-site-won-t-load-for-me-all-i-see-is-the-soundcloud-logo-what-can-i-do- 
 
http://google.com/chrome 
 
http://firefox.com/ 
 
http://apple.com/safari 
 
http://windows.microsoft.com/ie 
 
http://help.soundcloud.com/

相關問題