我有一个wget
名为的脚本Chktitle.sh
——这个脚本接受如下命令
$ Chktitle.sh "my url"
然后我有一个超过 100 行的文件名url.txt
,其中包含 url 和 ips 来检查网页标题。然后我有results.txt
一个空白文件。
有什么方法可以对文件中的每一行执行如下重复操作:
Grab line1 from url.txt
-----
then execute Chktitle.sh "line1"
-----
Now save the result for line1 in results.txt
-----
Now goto Line2 ........
etc etc etc
我需要确保它只会在前一行完成后才执行下一行。任何人都可以告诉我任何简单的方法来执行此操作吗?我很高兴使用 Perl、sh 并考虑其他语言。
的内容chktitle.sh
:
#!/bin/bash
string=$1"/search/"
wget --quiet -O - $string \
| sed -n -e 's!.*<title>\(.*\)</title>.*!\1!p'