1

I am new in shell script / bash scripting. I follow many document to download the file into current date folder. I used below method to download the file like

currentdate = $(date +"%d-%m-%Y")
wget -o currentdate/file.csv  http://someurl/file/

This example URL (orignal is changed) "http://someurl/file/" downloads the CSV file if hit.

kvantour
  • 25,269
  • 4
  • 47
  • 72
Smith
  • 148
  • 13
  • 1
    https://stackoverflow.com/questions/2268104/command-not-found-error-in-bash-variable-assignment – William Pursell Aug 07 '20 at 13:12
  • you have to prefix your variable in wget commant like this : `wget -o ${crrentdate}/file.csv ........` – francois P Aug 07 '20 at 13:14
  • 2
    You are missing a couple of things, but in a single command you can do : `wget -o "/path/to/$(date "+%F")/file.csv" http://someurl/file`. This would also be the line you can use in your crontab (see old deleted question)). Notice that I used `%F` as a folder. This makes a folder in the form YYYY-MM-DD which is sortable in contrast to your format "%d-%m-%Y". You might also be interested in adding `mkdir -p "/path/to/$(date "+%F")"` just before. – kvantour Aug 07 '20 at 13:15
  • 2
    @kvantour Do you mean `-O` instead of `-o`? – choroba Aug 07 '20 at 13:20
  • @choroba It depends. It could be that the user wants the log file with `-o` or the downloaded file with `-O` – kvantour Aug 07 '20 at 13:25
  • @kvantour this is not working just put logs in csv file dowload 0 per,20 per,etc – Smith Aug 07 '20 at 13:33
  • in place of wget if i am using curl its working fine – Smith Aug 07 '20 at 13:37
  • @Dev read comments – alecxs Aug 07 '20 at 16:29

0 Answers0