In a txt file, I have a list of sites that I'd like to visit. Each of them provides a list of pages on the particular site to be visited (when called without page parameter) via list.php. The problem is that the inside loop is getting executed right after the first pass through the outside loop and that causes running multiple instances of chromium browser. What I'd like to achieve is visiting each page and closing the browser after that, then visiting another etc.
while read sites; do wget -qO- "$sites/list.php" | while read page; do chromium "$sites/$page" & sleep 1 pkill --oldest chromium wget -qO- "$sites/list.php?page=$page" done done < sites.txt