I need to copy the last file created in a directory to another via ssh
.
I am using the following command:
ssh -oStrictHostKeyChecking=no user@IP "cd /home/user/backup_database/hour/; cp "'ls -1trap | grep -v '/$' | tail -n 1'" ~/"
The command returns the following error when I run the script:
cp: can not stat 'shutdown.sh': No such file or directory
If you can help me with a command or some other solution.