linux - Diff between two remote folders through SSH -
Do anyone know how to list files in a remote folder and not in other remote folders? I have two servers (called Server 1 and Server 2) with the same folder structure where I am Rsync However, in the Destination folder there are more files than the source because some files were deleted. Now I am trying to find a way to find which new files in Server2 using diff
between Server2 and Server 2.
I can take the difference between two local folders directly using the following command:
diff / home / www / images / test_images / var / www / site / Images / test_images
But I was wondering if the difference between two remote servers using SSH is possible for folders like this?
diff ubuntu1@images.server1.com: / home / www / images / test_images ubuntu2@images.server2.com: / var / www / site / images / test_images
< / Pre>The SSH configuration of Server 1 and Server 2 are as follows:
Server 1
IP: Images.server1. Com user: ubuntu1 password: pa $$ word1 image path: / home / www / images / test_images
server2
IP: images.server2.com User: ubuntu2 Password: pa $$ Word2 Image Path: / var / www / site / images / test_imaj
Hope any help to this problem to solve. Thank you.
Try this command:
diff-B & lt; (Find Sshpass -p 'pa $$ word1' ssh ubuntu1@images.server1.com "/ home / www / images / test_images -type f | sed 's / \ / home \ / www \ / image / test_images / / / G '"| sort-n) & lt; (Find sshpass -p 'pa $$ word2' ssh ubuntu2@images.server2.com "/ var / www / site / images / test_images -type f | sed 's / \ / var \ / www \ site / images / test_images \ /// g '"| sort -n) | Grep "& gt; | You can change the
ssh in two servers without interrupting your passworddiff-B & lt; () Explanation:
Command first to differentiate between two currents Used in)
sshpass
sed
for each parameter specify all your images in the code To use thesearch
command to always be listed in the list and to delete the root path of thesed
files (because they are two heads Different for Vron - anddiff
to work for the command); Andsort
commandto sort them, because
diff
command > or>
or< Lt; The result of
,grep
> is used to filter only one diff from your server. Last,awk
prints only the second column (deletes the& gt;
column from the output).Note: You must first install
sshpass
. Useapt-get
to set it below:sudo apt-get install sshpass
Other commands like
rm
are hopeful that this works for you.
Comments
Post a Comment