![](/img/trans.png)
[英]Renaming the output file name from ffmpeg when using find and xargs
[英]Copy line of text from input to output file while using xargs
我有一個工作的shell腳本,它讀取包含URL的文本文件,每個文件都在一個單獨的行上。 從文件中並行讀取URL並檢查其狀態代碼,其中響應寫入status-codes.csv。
如何將url-list.txt中引用的原始URL寫入status-codes.csv的第一列輸出?
status-codes.sh
#!/bin/bash
xargs -n1 -P 10 curl -u user:pass -L -o /dev/null --silent --head --write-out '%{url_effective},%{http_code},%{num_redirects}\n' < url-list.txt | tee status-codes.csv
網址LIST.TXT
http://website-url.com/path-to-page-1
http://website-url.com/path-to-page-2
http://website-url.com/path-to-page-3
status-codes.csv (電流輸出)
http://website-url.com/path-to-page-2,200,1
http://website-url.com/path-to-page-after-any-redirects,200,2
http://website-url.com/404,404,2
status-codes.csv (期望輸出)
http://website-url.com/path-to-page-2,http://website-url.com/path-to-page-2,200,1
http://website-url.com/path-to-page-1,http://website-url.com/path-to-page-after-any-redirects,200,2
http://website-url.com/path-to-page-3,http://website-url.com/404,404,2
使用-I
選項。 例如:
xargs -n1 -P 10 -I '{}' curl -u user:pass -L -o /dev/null --silent --head --write-out '{},%{url_effective},%{http_code},%{num_redirects}\n' '{}' < url-list.txt | tee status-codes.csv
man xargs
:
-I replace-str使用從標准輸入讀取的名稱替換 initial-arguments中出現的replace-str 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.