如何递归地卷曲所有文件
How to curl all files recursively
这是我目前使用的代码:
xargs -n 1 curl -s -o /dev/null -w "%{http_code} - %{url_effective}\n" < 'file.txt'
这适用于卷曲 file.txt
中的所有 URL 并获取状态代码和卷曲的 URL。但是,我需要对每个文件递归执行此操作。
我已经尝试了一些方法,例如这样,但是 none 成功了:
xargs -n 1 curl -s -o /dev/null -w "%{http_code} - %{url_effective}\n" < *
多个目录中大约有 3000 个文件。有没有办法递归地做到这一点?
假设你的文件列表的名称有这样的规则:file.txt、file1.txt、file2.txt在当前工作目录下,包括子目录。
您可以使用 cat **/file*.txt
命令合并这些文件中的所有链接,然后将其与 xargs
:
合并
cat **/file*.txt | xargs -n 1 curl -s -o /dev/null -w "%{http_code} - %{url_effective}\n"
祝你好运!
这是我目前使用的代码:
xargs -n 1 curl -s -o /dev/null -w "%{http_code} - %{url_effective}\n" < 'file.txt'
这适用于卷曲 file.txt
中的所有 URL 并获取状态代码和卷曲的 URL。但是,我需要对每个文件递归执行此操作。
我已经尝试了一些方法,例如这样,但是 none 成功了:
xargs -n 1 curl -s -o /dev/null -w "%{http_code} - %{url_effective}\n" < *
多个目录中大约有 3000 个文件。有没有办法递归地做到这一点?
假设你的文件列表的名称有这样的规则:file.txt、file1.txt、file2.txt在当前工作目录下,包括子目录。
您可以使用 cat **/file*.txt
命令合并这些文件中的所有链接,然后将其与 xargs
:
cat **/file*.txt | xargs -n 1 curl -s -o /dev/null -w "%{http_code} - %{url_effective}\n"
祝你好运!