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.
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
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
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 ?
That would be
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.