开发者

Linux: how to display file within the same date

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.


(I am currently sitting on a windows machine, so the command syntax is just by memory)

You can use find for this:

find /your/dir -maxdepth 1 -mtime 2011-07-02 -print0 | xargs -0 ls -lath


I advice to use

find -ctime 2

if you want to find files that were changed during the last 2 days or

find -cnewer test

If you are just interested in files that have a younger modification date than the file 'test'.


grep without cutting, it would be rare false positive match; and if you want just the file name, cut at the end.


You want to grep and then cut, although I would use nawk:

ls -alth | nawk '{for (i=8; i<=NF;i++) printf("%s ",$i); printf("\n")}'


This is the answer

ls -alth | grep 2011-07-02
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜