Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Wget with date variable

TH_GeorgeTH_George Member
edited April 2016 in Help

Hello,

I would like some help from anyone that knows a bit more about unix commands.
I am trying to set a cron with wget command to retreive a file that will be generated automatically everytime that is requested.

The file is created in this format --> 00000_year_month_date.xml
where year,month and date are numbers of the exact moment the wget takes place.
Also month for example is plain 4 for April and not 04.

Is there a way to make the wget use variables in the place of year,month and date to make this happen?

Thank you for your time.

George

Comments

  • blackblack Member
     wget location -O "`date`.xml" 

    You can use +% after date to specify your format.

  • Thank you for taking the time to reply.

    What I mean is this file name is in the "location" section

    So I want to do

    wget http://samplesite.com/00000_'date'.xml -O "savedfile.xml"

    Will the date variable work in the "location" part ?

  • blackblack Member

    That would be

     wget "http://somesite/00000_`date`.xml" 

    the -O option is tell it to save the file as a different name. I thought you meant you want to save it as a special name, not grab a special named file so -O might not even be needed.

  • Haven't tried it yet, but the date format could be something like

    date +%Y_%-m_%d

    The %-m is a GNU date feature that removes the zero-padding from the month.

Sign In or Register to comment.