Shell command

1

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.

    
asked by anonymous 19.01.2018 / 15:14

1 answer

1

The commands used are correct, but the use of the quotes in the wrong place causes the error.

Follows:

ssh -oStrictHostKeyChecking=no user@IP "cd /home/user/backup_database/hour/ && cp 'ls -1trap | grep -v '/$' | tail -n 1' ~/"
    
19.01.2018 / 18:15