Created
May 14, 2018 20:11
-
-
Save Lerie82/3019d4e0e6793f1598b3dd52daa075d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
counter=10 | |
curl https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty > /var/www/html/pbr/tmp/hnews | |
cat /var/www/html/pbr/tmp/hnews |grep -o '[0-9]\{7,8\}' > /var/www/html/pbr/tmp/hnews2 | |
truncate -s 0 /var/www/html/pbr/tmp/hnews | |
echo '[' >> /var/www/html/pbr/tmp/hnews | |
cat /var/www/html/pbr/tmp/hnews2 | while read -r line; | |
do | |
curl https://hacker-news.firebaseio.com/v0/item/$line.json?print=pretty >> /var/www/html/pbr/tmp/hnews | |
counter=$((counter-1)) | |
if [ $counter -eq 0 ] | |
then | |
echo ']' >> /var/www/html/pbr/tmp/hnews | |
exit 1 | |
else | |
echo ',' >> /var/www/html/pbr/tmp/hnews | |
fi | |
done | |
rm /var/www/html/pbr/tmp/hnews2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment