1

Trying to script a file download in Ubuntu from an SMB network server (windows-esque).

I have a folder tree as follows:

  • file1.tar.gz
  • file2.tar.gz
  • file3.tar.gz

These files have different modified dates.

I want to download the latest file using smbclient, get requires a file name which I won't know what the latest file name is (it won't necessarily be in numeric order).

How do I get the last created file using smbclient? Is there a specific mask in mget to do this?

I also hopefully want to do this without any interaction from the user (part of a shell script).

1 Answers1

0

Mount share to some directory then use ls -1t to list files sorted according to modification time.

ls -1t /mnt/file*.tar.gz | head -n 1
John Doe
  • 101