簡體   English   中英

本地/遠程服務器中相同文件上的不同 md5sum

[英]Different md5sum on same files in local / remote server

我想檢查我在本地機器上的文件列表的 md5sum,並將其與我復制到遠程服務器上的相同文件的 md5sum 進行比較。

如果我在每台機器上的終端中分別檢查:

# local
find . -type f -name "*.fastq.gz" -exec md5sum {} + | awk '{print $1}' | sort | md5sum
> 5a58015f2abec5bb1ee3e6a003ec4beb  -

# remote
find . -type f -name "*.fastq.gz" -exec md5sum {} + | awk '{print $1}' | sort | md5sum
> 5a58015f2abec5bb1ee3e6a003ec4beb  -

現在,如果我將這些命令運行到 bash 腳本中:

path_local="path/to/data/"
server_remote="user@ip.adress"
path_remote="path/to/data/"

local_md5sum=$(find ${path_local} -type f -name "*.fastq.gz" -exec md5sum {} + | awk '{print $1}' | sort | md5sum)
echo "local_md5sum : ${local_md5sum}"
remote_md5sum=$(ssh ${server_remote} "find ${path_remote} -type f -name '*.fastq.gz' -exec md5sum {} + | awk '{print $1}' | sort | md5sum")
echo "remote_md5sum : ${remote_md5sum}"

> local_md5sum : 5a58015f2abec5bb1ee3e6a003ec4beb  -
> remote_md5sum : 4a32580085edf9e49e00c46920517dd1  -

我在腳本中看到的唯一區別是,我對'*.fastq.gz'使用了簡單的引號,而不是我之前的命令中的雙引號。 但我必須或我得到find: paths must precede expression錯誤find: paths must precede expression

為什么我沒有相同的 md5sum,我該如何解決這個問題?

您遇到了引用問題:在遠程服務器部分,您需要轉義$ ,如下所示: awk '{print \\$1}'

結果:

remote_md5sum=$(ssh ${server_remote} "find ${path_remote} -type f -name '*.fastq.gz' -exec md5sum {} + | awk '{print \$1}' | sort | md5sum")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM