如何比较两个目录中的时间戳

时间:2019-01-29 05:39:46

标签: bash shell unix

我有一个问题,该如何检查备份目录中是否已存在文件,比较两个文件的更新时间,然后根据需要进行更新。

谢谢!

#!/bin/bash

echo "Enter a directory name" 
read dirtydan

if [ -d "$dirtydan" ]; then
echo "directory exists."
else
echo "Error: directory does not exist."

echo -n "Do you want to make $dirtydan as new directory (y/n)? "
read answer

if [ "$answer" != "${answer#[Yy]}" ] ;then
echo yes
echo "Making $dirtydan as directory"
mkdir -p $dirtydan
else
echo No
echo "Goodbye"
fi

fi

find $pwd -name '*.txt' -exec cp -t $dirtydan "{}" +

0 个答案:

没有答案
相关问题