How to filter the output of ls command to display only files created in February?
Asked Answered
F

2

41

For Linux OS, How to filter the output of ls command in terminal to display only files created in February?

Flavour answered 20/4, 2015 at 0:13 Comment(4)
It's an off-topic as it related to superuser.Abernethy
try this: find Folder_name -type f -ls |grep 'Feb'Surakarta
Although it is related to superuser, there are a lot of answers to question. I would go with ls -l ? | grep Feb. I add the question mark because this will setup your time. Here you can print based on modification time, creation time, etc. It's up to you, read the man pages.Berthold
Don't parse ls: mywiki.wooledge.org/ParsingLsAnarchism
F
45
touch --date "yyyy-mm-dd" /tmp/start
touch --date "yyyy-mm-dd" /tmp/end
find /my/path -type f -newer /tmp/start -not -newer /tmp/end

or

ls -l  | grep 'yyyy-mm-dd'
Flavour answered 22/4, 2015 at 23:36 Comment(0)
R
24

You can simple grep the output to filter out only Feb files

ls -l | grep "Feb"

If you want to filter out files in the sub directories also then

ls -l -R | grep "Feb"

Note

  • R flag means recursive
Riding answered 31/8, 2017 at 7:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.