我有一个将一些文件创建到文件夹中的过程。
在运行该过程后,我需要确定添加了哪些文件。我在 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
之后创建的所有文件。创建的文件
关于linux - 在 bash 中获取新添加的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63864956/