Files Modified Recently With Zsh
Sometimes, there’s a directory of files and we just want to know the files that are recently modified in say, the last day.
With zsh, we can do this with something like:
ls /usr/local/*(mh-1)
This will show us all files modified in the last hour. We can also replace the h
with a w
for weeks, a d
for days, M
for months, m
for minutes, and s
for seconds.
The nice thing is this actually goes really well with other commands - for example, we can tar up all files modified in the last day using something like this:
tar -cvf recent.tar /usr/local/*(mh-1)
Pretty nifty! I learned this (and many other neat zsh tricks) from Outrageously Useful Tips to Master your Z-Shel.