Linux:如何显示同一日期内的文件
所以在Linux中,如果我这样做ls -alth
,那么它会显示文件夹内的所有文件以及最后修改的日期。我想显示在特定日期最后修改的文件。我该如何实现这一目标。所以我尝试这样做
ls -alth | cut -f7 -d " " | grep 2011-07-02
,以便显示所有内容 ->然后通过管道传输到解析器 ->然后将字段 7(即日期)的结果通过管道传递给 grep 以过滤到我想要的日期。好吧,结果就是
2011-07-02
2011-07-02
2011-07-02
...
我想查看文件名。
so in linux, if I do this ls -alth
, then it display all files inside a folders with the date of last modifications. I want to display files that last modify on a particular date. How do I achieve that. So I try this
ls -alth | cut -f7 -d " " | grep 2011-07-02
so display every thing -> then pipe to a parser -> then pipe the result at field 7, which is the date, to grep
to filter down to the date that I want. Well the result is all
2011-07-02
2011-07-02
2011-07-02
...
I want to see the file name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
(我目前坐在 Windows 机器上,所以命令语法只是凭记忆)
你可以使用
find
来实现:(I am currently sitting on a windows machine, so the command syntax is just by memory)
You can use
find
for this:我建议使用。
如果您想查找最近 2 天内更改的文件,或者
您只是对修改日期比文件“测试”更早的文件感兴趣,
I advice to use
if you want to find files that were changed during the last 2 days or
If you are just interested in files that have a younger modification date than the file 'test'.
grep 不进行剪切,很少会出现误报匹配;如果您只想要文件名,请在末尾处剪切。
grep without cutting, it would be rare false positive match; and if you want just the file name, cut at the end.
你想要 grep 然后剪切,尽管我会使用 nawk:
You want to grep and then cut, although I would use nawk:
这就是答案
This is the answer