Live Gold Price For Linux Bash Script Example
Page 1 of 1
Live Gold Price For Linux Bash Script Example
- 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
Re: Live Gold Price For Linux Bash Script Example
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
Re: Live Gold Price For Linux Bash Script Example
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
Re: Live Gold Price For Linux Bash Script Example
For More
Visit
jnet.forumotion.com/t526-setting-up-linux-cronjobs#724
Visit
jnet.forumotion.com/t526-setting-up-linux-cronjobs#724
Re: Live Gold Price For Linux Bash Script Example
Run this automatically with a Cronjob
https://jnet.forumotion.com/t526-setting-up-linux-cronjobs#2547
https://jnet.forumotion.com/t526-setting-up-linux-cronjobs#2547
Re: Live Gold Price For Linux Bash Script Example
Monday - Friday 9 - 5
- Code:
0 9-17 * * 1-5 /home/jay/Documents/Scripts/Gold/gold.sh >/dev/null 2>&1
Similar topics
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Convert MP4 To MP3 Linux Bash Script
» Linux Bash Dog Age Calculator Script
» BASH Linux Talking IP Script
» Linux Random Name Picker Bash Script Example
» Convert MP4 To MP3 Linux Bash Script
» Linux Bash Dog Age Calculator Script
» BASH Linux Talking IP Script
» Linux Random Name Picker Bash Script Example
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum