Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

how to use find in scp command

Writer Sophia Terry

I would like to use scp command fo transfer some files from remote server to local machine. The problem I have is to find the files and then direct them to scp command. I don't want to generate an ssh-key on the server, so I have to use the command from the local machine to perform the task.

Actually, I need something like below: scp username@server_IP:/path/to/file/`find . -ctime -1 -type f` ./The problem is that find command does not work.

Please advice.

5

1 Answer

  • Create a local target directory

    mkdir /path/to/targetdir
  • Identify the remote source directory /path/to/sourcedir

  • Run the following one-liner (edited with the correct source and target directories and user@ip-address for the server),

    ssh username@ip-adress '(cd /path/to/sourcedir; find . -print | cpio -oBav -Hcrc)' | ( cd /path/to/targetdir && cpio -ivumd )
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy