Search code examples
bashwgetrsync

How to automatically move a fully downloaded file to a new directory


I am using wget to download files a group of files to be ingested in a program. I know I can use the "-P" to send the file to a tmp directory, but I am unsure what the best method is to move the file to the needed destination once fully downloaded. Is rsync the best way to move the files or is another method preferred using scripting?


Solution

  • If you intend to move a file if the download is properly done then make a move or if it is not downloaded properly then no need of move, then you can use "LOGICAL AND" between the commands of wget and mv

    wget http://mysite.example.com/file1.tgz && mv file1.tgz /new_dest/