Live Gold Price For Linux Bash Script Example

Go down

Live Gold Price For Linux Bash Script Example

Post by jamied_uk on 9th June 2018, 19:22



Code:
#!/bin/bash
# (c) J~Net 2018
# jnet.forumotion.com/t1633-live-gold-price-for-linux-bash-script-example#2513
#
# Example:
#
# ./gold.sh
#
#
cd /home/jay/Documents/Scripts/Gold
# current_directory=`pwd`
# cd $current_directory
wget https://www.bullionbypost.co.uk/gold-price/live-gold-price/ -O out.html
cat out.html | grep "data-currency" > out.txt
#
cat out.txt | sed 's/[^.0-9]*//g' > new.txt
# need to remove  <td title="Current Gold Price">£<span name="current_price_field" data-currency="default">
clear
dt=$(date +%d-%m-%Y)
Time=$(date "+%H-%M %p")
readarray a < new.txt
echo "$dt $Time Current Price For 1 Ounce Gold Is GBP £$a" > gold.txt
# use > to replace or >> to append above gold.txt file.
cat gold.txt >> gold-list.txt
# Remove empty lines.
sed -i '/^$/d' gold-list.txt
cat gold.txt
# Cleanup
rm *.html
rm out.txt
rm new.txt


Last edited by jamied_uk on 5th October 2018, 20:07; edited 3 times in total
avatar
jamied_uk
Admin

Posts : 2442
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Live Gold Price For Linux Bash Script Example

Post by jamied_uk on 9th June 2018, 19:38

With Date


Code:
#!/bin/bash
# (c) J~Net 2018
# jnet.forumotion.com/t1633-live-gold-price-for-linux-bash-script-example#2513
#
# Example:
#
# ./gold.sh
#
#
wget https://www.bullionbypost.co.uk/gold-price/live-gold-price/ -O out.html
cat out.html | grep "data-currency" > out.txt
#
cat out.txt | sed 's/[^.0-9]*//g' > new.txt
# need to remove  <td title="Current Gold Price">£<span name="current_price_field" data-currency="default">
clear
dt=$(date +%d-%m-%Y)
readarray a < new.txt
echo "$dt Current Prices For 1 Ounce Gold Is GBP £$a" > final.txt
cat final.txt
#
# echo $a


Last edited by jamied_uk on 9th June 2018, 20:26; edited 1 time in total
avatar
jamied_uk
Admin

Posts : 2442
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Live Gold Price For Linux Bash Script Example

Post by jamied_uk on 9th June 2018, 19:46



Tracking Prices Script



Code:
#!/bin/bash
# (c) J~Net 2018
# jnet.forumotion.com/t1633-live-gold-price-for-linux-bash-script-example#2513
#
# Example:
#
# ./track.sh
#
#
wget https://www.bullionbypost.co.uk/gold-price/live-gold-price/ -O out.html
cat out.html | grep "data-currency" > out.txt
# we want just the numbers for the price.
# below is to filter
cat out.txt | sed 's/[^.0-9]*//g' > new.txt
# need to remove  <td title="Current Gold Price">£<span name="current_price_field" data-currency="default">
clear
# date for tracking
dt=$(date +%d-%m-%Y)
readarray a < new.txt
# read lines as an array so only the 1st line can be echoed!
echo "$dt Current Price For 1 Ounce Gold Is GBP £$a" >> track.txt
# use > to replace or >> to append above track file.
cat track.txt
#
# echo $a
avatar
jamied_uk
Admin

Posts : 2442
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Live Gold Price For Linux Bash Script Example

Post by jamied_uk on 3rd July 2018, 14:25

avatar
jamied_uk
Admin

Posts : 2442
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Live Gold Price For Linux Bash Script Example

Post by jamied_uk on 5th October 2018, 12:04

For More

Visit

jnet.forumotion.com/t526-setting-up-linux-cronjobs#724
avatar
jamied_uk
Admin

Posts : 2442
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Live Gold Price For Linux Bash Script Example

Post by jamied_uk on 5th October 2018, 20:05

avatar
jamied_uk
Admin

Posts : 2442
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Live Gold Price For Linux Bash Script Example

Post by jamied_uk on 5th October 2018, 22:25

Monday - Friday 9 - 5

Code:
0 9-17 * * 1-5 /home/jay/Documents/Scripts/Gold/gold.sh >/dev/null 2>&1
avatar
jamied_uk
Admin

Posts : 2442
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Re: Live Gold Price For Linux Bash Script Example

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum