Answer the question
In order to leave comments, you need to log in
BASH How to create a dynamic variable?
Example
Using curl, a request is sent to the server, the title is extracted from the response and written to a file.
The list of URLs is taken from the file
Part of the script:
while read -r line
do
count_progress=$((++count_progress))
export tmp_var1=$(curl -s $line/ | grep '<title>' )
if [ "$tmp_var1" == "String" ]; then echo $line >> save_as; fi
printf "$count_progress checked\r"
done < $input
while read -r line
do
count_progress=$((++count_progress))
export tmp_var1=$(curl -s $line/ | grep '<title>' )&
if [ "$tmp_var1" == "String" ]; then echo $line >> save_as; fi&
printf "$count_progress checked\r"
done < $input
echo $line | awk '$0="tmp_"$0'
Answer the question
In order to leave comments, you need to log in
This should work, but the idea of running an uncontrolled number of parallel processes is also not particularly good:
while read -r line
do
count_progress=$((++count_progress))
(
export tmp_var1=$(curl -s $line/ | grep '<title>' )
if [ "$tmp_var1" == "String" ]; then echo $line >> save_as; fi
printf "$count_progress checked\r"
) &
done < $input
Vlad Zhivotnev has already given the correct answer :)
You have taken an inefficient path and are trying to make inefficient decisions instead of taking the right path ( parallel
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question