Listing today’s files only
Written by vaheeD on January 4, 2013
Listing today’s files only
- Difficulty: Easy
- Application: Various
You are probably familiar with the problem. Sometime earlier in the day, you created a text file, which now is urgently required. However, you can’t remember what ridiculous name you gave it, and being a typical geek, your home folder is full of 836 different files. How can you find it? Well, there are various ways, but this little tip shows you the power of pipes and joining together two powerful shell commands:
ls -al --time-style=+%D | grep `date +%D`
The parameters to the ls command here cause the datestamp to be output in a particular format. The cunning bit is that the output is then passed to grep. The grep parameter is itself a command (executed because of the backticks), which substitutes the current date into the string to be matched. You could easily modify it to search specifically for other dates, times, filesizes or whatever. Combine it with HACK 26 to save typing!