I have a list of urls in text file as following
https://example.com/test.php?x=1
https://example.com/test.php?x=1&y=2
and i`m doing while loop while executing certain command on those lines as following
while read line ;
do command ;
done < list.txt
i need to print on the terminal a counter down in the loop function so i can know the estimated time to end of list or another word to know the rest of lines to the end of list.
i have tried awk -v x="$url" '$0~x {print NR}
but did not work out
line
incommand
, use double quotes:"$line"
, because you might have characters like&
in$line
that have special meaning tobash
.;
.print ... counter down in loop
; do you mean something likeprocessing URL #3 of 10 ...
(where10
is the number of URLs/lines inlist.txt
)? or do you mean something else? it would help if you provide a few lines of the expected output as URLs are being processed in yourwhile
loopprocessing URL #3 of 10
which 10 is the number of lines in file