4

次のことを実現するには、bashシェルスクリプトを作成する必要があります。ディレクトリからすべてのファイルのリストを取得します。宛先ディレクトリで、これらのファイルのいずれかが存在する場合は、日付を比較します。ソースファイルが宛先ファイルよりも新しい場合にのみ、ファイルを宛先に直接コピーします。ファイルごとにこれを行う必要があります。コピー部分を実現するためにforループを作成しました。しかし、ファイルの日付を比較するのに助けが必要です。

ありがとう

4

3 に答える 3

5

man test

FILE1 -nt FILE2
          FILE1 is newer (modification date) than FILE2

FILE1 -ot FILE2
          FILE1 is older than FILE2

...
-e FILE
          FILE exists
....
于 2013-02-03T22:16:30.383 に答える
2
man cp | grep -C1 update

       -u, --update
              copy only when the SOURCE file is newer than the destination file or when the destination file is missing
于 2013-02-03T17:13:59.987 に答える
1

あなたはただcpをすることができるはずです。

cp -Ru /Your/original/path/ /destination/path/location/
于 2013-02-03T19:23:13.803 に答える