用于查找更新的和新添加的文件/文件夹的Unix命令
我需要找出已在文件系统路径/home/user01/myapps/中添加/更新的文件或文件夹在两个不同时间脚本开始和结束时间之间的列表 我正在运行一个Shell脚本,从不同的源向资源路径/home/user01/myapps/更新/添加新文件。因此,在脚本末尾,我想知道已添加或更新的文件或文件夹的列表 我有下面的命令 查找/opt/app/tds/tdsbatch-mtime-1 但是,我不确定脚本的运行时间用于查找更新的和新添加的文件/文件夹的Unix命令,unix,filesystems,find,command,Unix,Filesystems,Find,Command,我需要找出已在文件系统路径/home/user01/myapps/中添加/更新的文件或文件夹在两个不同时间脚本开始和结束时间之间的列表 我正在运行一个Shell脚本,从不同的源向资源路径/home/user01/myapps/更新/添加新文件。因此,在脚本末尾,我想知道已添加或更新的文件或文件夹的列表 我有下面的命令 查找/opt/app/tds/tdsbatch-mtime-1 但是,我不确定脚本的运行时间 真的需要帮忙 记录所需时刻的时间: # record the current time
真的需要帮忙 记录所需时刻的时间:
# record the current time in seconds on script startup
start_time=$(date +%s)
...
# do whatever you like
...
# to get the runtime in secods - if you like:
runtime=$(($(date +%s) - start_time))
# to get the runtime in minutes (minutes are useful for -mmin find param)
runtime=$((($(date +%s) - start_time) / 60))
...
# to record the finish time in seconds:
end_time=$(date +%s)
现在根据你的需要找。差不多
find /path \( -mmin $((-($(date +%s) - start_time) / 60)) \
-a $((($(date +%s) - end_time) / 60)) \)
第一个-mmin参数指定在当前时间后修改-脚本开始时间从现在算起的分钟数
第二个-mmin参数指定在当前时间之前修改-脚本结束时间(从现在算起)分钟
这两个参数都与-a参数结合在一起,并用前缀括号括起来
你可能需要这些。否则,我需要更多关于您需求的说明。要记录所需时刻的时间:
# record the current time in seconds on script startup
start_time=$(date +%s)
...
# do whatever you like
...
# to get the runtime in secods - if you like:
runtime=$(($(date +%s) - start_time))
# to get the runtime in minutes (minutes are useful for -mmin find param)
runtime=$((($(date +%s) - start_time) / 60))
...
# to record the finish time in seconds:
end_time=$(date +%s)
现在根据你的需要找。差不多
find /path \( -mmin $((-($(date +%s) - start_time) / 60)) \
-a $((($(date +%s) - end_time) / 60)) \)
第一个-mmin参数指定在当前时间后修改-脚本开始时间从现在算起的分钟数
第二个-mmin参数指定在当前时间之前修改-脚本结束时间(从现在算起)分钟
这两个参数都与-a参数结合在一起,并用前缀括号括起来
你可能需要这些。否则,我需要更多关于您需求的说明。在脚本开始时,您可以对任何现有文件使用touch命令或创建虚拟文件 e、 g 脚本开始 触摸filename1-它会将filename1的时间戳更改为当前时间 然后在脚本结束时,可以使用以下命令: 查找目录名-较新的文件名1
它将给出在该目录中filename1的时间戳之后修改或创建的所有文件在脚本开始时,您可以对任何现有文件使用touch命令或创建虚拟文件 e、 g 脚本开始 触摸filename1-它会将filename1的时间戳更改为当前时间 然后在脚本结束时,可以使用以下命令: 查找目录名-较新的文件名1
它将给出在该目录中filename1的时间戳之后修改或创建的所有文件什么是“不确定脚本运行时间”。请更新您的问题,以包括您需要的样本输出。祝你好运。你说的“不确定脚本运行时间”是什么意思。请更新您的问题,以包括您需要的样本输出。祝你好运