Finding files using grep

By Angela C

April 20, 2021 in shell Linux files

Reading time: 1 minutes.

Finding all files in a folder modified on a specific date using find and grep commands.

I needed to find files in a folder that I wanted to copy to another folder. Specifically I wanted to select all files that I edited today. The shell command ls -l will list details about the files including the date when the file was last modified, permissions etc.

The grep command can be used with the ls command to filter down to what you are looking for.

ls -l | grep '20 Apr' will allow me to find the files modified on the 20th April.

There is also the find command.

find . -type f -ls | grep '20 Apr' to find all files.

This will pick up ipynb checkpoints whereas ls -l | grep '20 Apr' did not.

To list all the files under the theme/mytheme folder:
find themes/mytheme -type f | xargs ls -l

To find all the index.html pages use the command:
find . -name index.html | xargs ls -l

To see the html files built in the public folder:
find public -type f -name '*.html' | xargs ls -l