linux - 在 bash 中获取新添加的文件
问题描述
我有一个将一些文件创建到文件夹中的过程。在运行该过程后,我需要确定添加了哪些文件。我在 Ubuntu 20 的 bash 中这样做
在 PowerShell 中,我可以这样做:
$filesBefore = (gci).Name
# ... -> here I run my process
$filesAfter = (gci).Name
$filesAfter | ? {$filesBefore -notcontains $_} # This will compare both list
在 Bash 中做类似事情的最佳方法是什么?
解决方案
查找进程创建的文件的一种方法是查找进程开始运行后修改时间的所有文件。
touch watch
# here you run your process
find . -newermm watch
touch watch
将创建一个文件名watch
find . -newermm watch
它将查找并打印创建文件后watch
创建的所有文件
推荐阅读
- php - PHP/Slim 有效的 MySQL 查询准备语句单独工作,但一起使用时失败
- typescript - Loopback 4 中应该如何实现模型验证?
- ios - 'dispatch_get_main_queue()' 的模糊使用
- html - 如何检查用户是否向下滚动(或交叉)到 Angular7 中的特定元素(基于 id)?
- openshift - Openshift oc rsh 增加超时
- html - 显示大内容的下拉菜单
- audio - 如何测量智能手机的音频质量?
- c - 条件始终为真。我的代码中的错误,或我的 IDE 中的错误?
- java - 如果没有元描述,谷歌如何获得维基百科页面的描述?
- sql - 在 SQL Server 表中将一列拆分为多列,但某些无效值未对齐