Hi:
I have a simple task - to copy, in Linux, the latest xml from one folder to another folder (or ftp to another server). Can't find the command to pick up the latest file. Can UNIX gurus help poor Windows guy?
Thanks a lot. It does find the latest file, great! But complains that: cannot stat 'filenametocopy': No such file or directory. Funny, it does find filenametocopy right, maybe it's smth with single quotation marks?
[tt]cp $(ls -t /source/directory/* | head -1) /destination/directory[/tt]
That way the ls command displays the filenames with full paths. Alternatively if there are (or may be) many files in that directory it may be safer to do this:
[tt]cd /source/directory
cp $(ls -t | head -1) /destination/directory[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.