I have a wget
script named Chktitle.sh
-- this script takes a command like below
$ Chktitle.sh "my url"
I then have a file name url.txt
with over 100 lines with urls and ips to check for web-page titles.
Then i have results.txt
as a blank file.
Is there any way I can perform a repetitive action like below for each line in the file:
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
I need to make sure that it will only execute the next line after the previous one has finished. Can any one show me any easy way to perform this? I am happy to use Perl, sh, and consider other languages..
The contents of chktitle.sh
:
#!/bin/bash
string=$1"/search/"
wget --quiet -O - $string \
| sed -n -e 's!.*<title>\(.*\)</title>.*!\1!p'
Maybe something like this could help (provided that I understood correctly) :
For each line in
/path/to/input.txt
, execute your script and append the output (>>
) toresults.txt
.Of course you could always add additional statements in your while loop :