Script to do cronjob to download latest file and unzip it . SOLVED !

Andy5441

New Member
Joined
Jun 15, 2020
Messages
5
Reaction score
3
Credits
61
I use to go to a website http://testme.com/direct1/direct2/direct3/direct4/
to see latest file then do wget and untar it .

Where XXXXXXXX is number keep increase and I want to get the latest number link to download.
If the latest number is FN_29606118 ; then it will do
wget http://testme.com/direct1/direct2/direct3/direct4/FN_29606118.0_some_thing.tgz
tar -xvzf FN_29606118.0_some_thing.tgz

Can we do a shell script so we can do cronjob at 8am? How it can find what is latest or highest XXXXXXXXX number ?

I only can do this; but I have to check what is latest number
#!/bin/sh
LOC=`pwd`

mkdir $LOC/$1


if [ $# -eq 1 ] ; then
cd $LOC/$1
wget http://testme.com/direct1/direct2/direct3/direct4/FN_"$1".0_some_thing.tgz
tar -xvzf "$1".0_some_thing.tgz
fi
====
Can we do that ? Thanks .
 


I did it and it worked using wget with tail -1 | grep -Po 'FN_\d{8}' to get FN_XXXXXXXX
Then use this number to download and untar. Thanks
 

Members online


Latest posts

Top