我是shell腳本編程新手。我通過python從郵件中提取了一些URL,但腳本解碼的URL被破壞了。所以我認爲是編寫一個代碼,以便我只能提取所需的URL。Shell extract broken URL's
以下是文件:
http://stackoverflow.com/questions/17988756/=
how-to-select-lines-between-two-marker-patterns-which-may-occur-multiple-times-w
.
.
.(some text)
http://stackoverflow.com/questions/9605232/=
merge-two-lines-into-one
.
.
.
所需的輸出是:
http://stackoverflow.com/questions/17988756/how-to-select-lines-between-two-marker-patterns-which-may-occur-multiple-times-w
http://stackoverflow.com/questions/9605232/merge-two-lines-into-one
在此先感謝。
我試着寫一些代碼: – Ritzz
而IFS =讀-r LINE 做 如果[[$行= 〜^ http://stackoverflow.com.*=]] then \t echo $ LINE >> broken_URL.txt \t回聲$ [LINE + 1] >> broken_URL.txt 音響 完成<文件 – Ritzz
和將在後面用sed 'N; S/= \ n //' broken_url.txt> broken_new_url.txt – Ritzz