<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ShellProven</title>
    <description>The latest articles on DEV Community by ShellProven (@shellprovenai).</description>
    <link>https://dev.to/shellprovenai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4257930%2F372c80cf-d3e4-4a6d-8e1e-2abb45b55708.png</url>
      <title>DEV Community: ShellProven</title>
      <link>https://dev.to/shellprovenai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shellprovenai"/>
    <language>en</language>
    <item>
      <title>Search a whole project with grep -r, without node_modules, .git or binary junk</title>
      <dc:creator>ShellProven</dc:creator>
      <pubDate>Mon, 23 Nov 2026 18:01:08 +0000</pubDate>
      <link>https://dev.to/shellprovenai/search-a-whole-project-with-grep-r-without-nodemodules-git-or-binary-junk-h01</link>
      <guid>https://dev.to/shellprovenai/search-a-whole-project-with-grep-r-without-nodemodules-git-or-binary-junk-h01</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AI disclosure:&lt;/strong&gt; this article was created with the help of AI. An AI assistant drafted the text from the lesson script, and it was reviewed before publishing. Every command was actually run in a fresh debian:13 container (GNU grep 3.11); all outputs below are copied from that run, not written by hand.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Search a whole project for a string with grep -r, then cut the noise: skip node_modules, .git and build folders with --exclude-dir, ignore binary files with -I, search only one file type with --include, match whole words with -w, and stop dots from acting as wildcards with -F.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt; You want to find every to-do in your project. You type &lt;code&gt;grep -r&lt;/code&gt;, and the screen fills with junk from &lt;code&gt;node_modules&lt;/code&gt;, dot git, and minified files.&lt;/p&gt;

&lt;h2&gt;
  
  
  The noisy first search
&lt;/h2&gt;

&lt;p&gt;Our demo project has source code in src, a dependency in &lt;code&gt;node_modules&lt;/code&gt;, a dot git folder, a minified build in dist, a compiled binary, and a log file. Here is the search everyone types first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -r &lt;span class="s2"&gt;"TODO"&lt;/span&gt; .
./src/client.js:// TODO: handle errors
./src/auth.py:    &lt;span class="c"&gt;# TODO: rate limit&lt;/span&gt;
./.git/config:  &lt;span class="c"&gt;# TODO nothing&lt;/span&gt;
./node_modules/left-pad/index.js:// TODO upstream bug
./dist/app.min.js:function a&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;/*TODO*/return 1&lt;span class="o"&gt;}&lt;/span&gt;
grep: ./bin/tool: binary file matches
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only two of these lines are our code. One comes from a dependency, one from git's own config, one from the minified build, and the last line is a binary file that happens to contain the text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Skip folders with --exclude-dir
&lt;/h2&gt;

&lt;p&gt;Let's skip the folders we never want. &lt;code&gt;--exclude-dir&lt;/code&gt; takes a folder name, and you can repeat it. I'm also adding &lt;code&gt;-n&lt;/code&gt; for line numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rn &lt;span class="s2"&gt;"TODO"&lt;/span&gt; --exclude-dir=node_modules --exclude-dir=.git .
./src/client.js:1:// TODO: handle errors
./src/auth.py:2:    &lt;span class="c"&gt;# TODO: rate limit&lt;/span&gt;
./dist/app.min.js:1:function a&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;/*TODO*/return 1&lt;span class="o"&gt;}&lt;/span&gt;
grep: ./bin/tool: binary file matches
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Better. The dependency and the git config are gone. Note that you give the folder name, not a path, so it skips &lt;code&gt;node_modules&lt;/code&gt; at any depth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ignore binary files with -I
&lt;/h2&gt;

&lt;p&gt;Two problems left: the build folder and the binary. Typing &lt;code&gt;--exclude-dir&lt;/code&gt; again and again is tedious, so here's a shortcut. In bash, a comma list in curly braces expands into several options. And capital &lt;code&gt;-I&lt;/code&gt; tells grep to skip binary files completely.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rnI &lt;span class="s2"&gt;"TODO"&lt;/span&gt; --exclude-dir=&lt;span class="o"&gt;{&lt;/span&gt;node_modules,.git,dist&lt;span class="o"&gt;}&lt;/span&gt; .
./src/client.js:1:// TODO: handle errors
./src/auth.py:2:    &lt;span class="c"&gt;# TODO: rate limit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two lines, both from our own code. That is the search you actually wanted. One detail: the curly-brace trick is a bash feature. If a script runs under plain sh, write the options out one by one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Case, file types and file names
&lt;/h2&gt;

&lt;p&gt;Did we miss anything? Let's add &lt;code&gt;-i&lt;/code&gt; to ignore case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rniI &lt;span class="s2"&gt;"todo"&lt;/span&gt; --exclude-dir=&lt;span class="o"&gt;{&lt;/span&gt;node_modules,.git,dist&lt;span class="o"&gt;}&lt;/span&gt; .
./src/main.py:2:# todo: remove debug flag
./src/client.js:1:// TODO: handle errors
./src/auth.py:2:    &lt;span class="c"&gt;# TODO: rate limit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There was a lowercase to-do hiding in main dot py. Case-sensitive search had quietly skipped it. Sometimes you only care about one language. &lt;code&gt;--include&lt;/code&gt; limits the search to matching file names, and &lt;code&gt;-l&lt;/code&gt; prints just the file names, not the lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rl &lt;span class="s2"&gt;"TODO"&lt;/span&gt; --include=&lt;span class="s2"&gt;"*.py"&lt;/span&gt; .
./src/auth.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the quotes around the star. Without them, the shell may expand it before grep ever sees it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Whole words with -w
&lt;/h2&gt;

&lt;p&gt;Next trap. Let's look for the word log.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rn &lt;span class="s2"&gt;"log"&lt;/span&gt; logs src
logs/app.log:1:2026 login ok
logs/app.log:2:2026 user log out
src/client.js:2:fetch&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/catalog"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
src/auth.py:1:def login&lt;span class="o"&gt;(&lt;/span&gt;user&lt;span class="o"&gt;)&lt;/span&gt;:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We get login, catalog, and log out. grep matches text anywhere, even inside longer words. &lt;code&gt;-w&lt;/code&gt; only accepts whole words.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rnw &lt;span class="s2"&gt;"log"&lt;/span&gt; logs src
logs/app.log:2:2026 user log out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now only the line where log is a word of its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dots are wildcards: use -F
&lt;/h2&gt;

&lt;p&gt;Let's find the version one point five.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rn &lt;span class="s2"&gt;"1.5"&lt;/span&gt; src logs
src/main.py:4:VERSION &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"1.5"&lt;/span&gt;
logs/app.log:3:version 105 started
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Surprise: we also matched one hundred and five in the log. In a pattern, a dot means any single character. &lt;code&gt;-F&lt;/code&gt; treats the pattern as plain text. Use it whenever you search for something with dots, brackets or stars in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rnF &lt;span class="s2"&gt;"1.5"&lt;/span&gt; src logs
src/main.py:4:VERSION &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"1.5"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Several patterns and some context
&lt;/h2&gt;

&lt;p&gt;To look for several things at once, use &lt;code&gt;-E&lt;/code&gt; and separate the patterns with a vertical bar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -rnIE &lt;span class="s2"&gt;"TODO|FIXME|DEBUG"&lt;/span&gt; --exclude-dir=&lt;span class="o"&gt;{&lt;/span&gt;node_modules,.git,dist&lt;span class="o"&gt;}&lt;/span&gt; .
./src/main.py:3:DEBUG &lt;span class="o"&gt;=&lt;/span&gt; True
./src/client.js:1:// TODO: handle errors
./src/auth.py:2:    &lt;span class="c"&gt;# TODO: rate limit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And when one line isn't enough to understand a match, &lt;code&gt;-A 1&lt;/code&gt; shows one line after it. Capital B shows lines before, and capital C both.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ grep -n -A 1 &lt;span class="s2"&gt;"TODO"&lt;/span&gt; src/auth.py
2:    &lt;span class="c"&gt;# TODO: rate limit&lt;/span&gt;
3-    &lt;span class="nb"&gt;return&lt;/span&gt; check&lt;span class="o"&gt;(&lt;/span&gt;user&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The trap, in one paragraph
&lt;/h2&gt;

&lt;p&gt;In a grep pattern the dot is a wildcard. Searching for &lt;code&gt;1.5&lt;/code&gt; also matches &lt;code&gt;105&lt;/code&gt;. Add &lt;code&gt;-F&lt;/code&gt; to treat the pattern as plain text: &lt;code&gt;grep -rnF "1.5"&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick check
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. I search for version 1.5 and grep also matches 105. Which option fixes that?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-w&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-F&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-i&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;
  Answer
  &lt;br&gt;
&lt;strong&gt;&lt;code&gt;-F&lt;/code&gt;&lt;/strong&gt;: &lt;code&gt;-F&lt;/code&gt; treats the pattern as plain text. Without it, the dot matches any character.&lt;br&gt;


&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. I search for the word log and also get login and catalog. Which option keeps only whole words?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-w&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-F&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-l&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;
  Answer
  &lt;br&gt;
&lt;strong&gt;&lt;code&gt;-w&lt;/code&gt;&lt;/strong&gt;: &lt;code&gt;-w&lt;/code&gt; accepts a match only when it is a word of its own.&lt;br&gt;


&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Recap
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;grep -rnI&lt;/code&gt; searches recursively, with line numbers, and skips binaries. &lt;code&gt;--exclude-dir&lt;/code&gt; removes folders like &lt;code&gt;node_modules&lt;/code&gt; and dot git. Add &lt;code&gt;-i&lt;/code&gt; for case, &lt;code&gt;--include&lt;/code&gt; for one file type, &lt;code&gt;-w&lt;/code&gt; for whole words, and &lt;code&gt;-F&lt;/code&gt; when your text has dots in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source and reproducible setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Lesson page with the same quiz (and a video version): &lt;a href="https://shellprovenai.github.io/lekcje/grep-r-excludes/" rel="noopener noreferrer"&gt;https://shellprovenai.github.io/lekcje/grep-r-excludes/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Commands, demo setup script and full test log: &lt;a href="https://github.com/shellprovenai/terminal-tutorials/tree/main/grep-r-excludes" rel="noopener noreferrer"&gt;https://github.com/shellprovenai/terminal-tutorials/tree/main/grep-r-excludes&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was created with the help of AI and reviewed before publishing. The video on the lesson page uses AI narration and AI-generated robot-and-dog presenters. No sponsors, no affiliate links.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>cli</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Find files changed in the last 24 hours (and the -mtime +1 trap)</title>
      <dc:creator>ShellProven</dc:creator>
      <pubDate>Sun, 22 Nov 2026 09:01:22 +0000</pubDate>
      <link>https://dev.to/shellprovenai/find-files-changed-in-the-last-24-hours-and-the-mtime-1-trap-m9m</link>
      <guid>https://dev.to/shellprovenai/find-files-changed-in-the-last-24-hours-and-the-mtime-1-trap-m9m</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AI disclosure:&lt;/strong&gt; this article was created with the help of AI. An AI assistant drafted the text from the lesson script, and it was reviewed before publishing. Every command was actually run in a fresh debian:13 container (GNU findutils 4.10.0, GNU tar 1.35); all outputs below are copied from that run, not written by hand.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Find every file that changed in the last 24 hours, understand why &lt;code&gt;-mtime +1&lt;/code&gt; silently skips files that are almost two days old, skip folders like node_modules with &lt;code&gt;-prune&lt;/code&gt; (and why you need &lt;code&gt;-print&lt;/code&gt;), and back up the results safely with &lt;code&gt;-print0&lt;/code&gt; and tar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem:&lt;/strong&gt; Something on your server changed since yesterday, and you want to know what. The tool for that is &lt;code&gt;find&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The demo folder
&lt;/h2&gt;

&lt;p&gt;First, a small project to play with. I gave each file a different modification time with &lt;code&gt;touch -d&lt;/code&gt;, from ten minutes ago up to five days ago.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -type f -printf &lt;span class="s1"&gt;'%TY-%Tm-%Td %TH:%TM  %p\n'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort
2026-11-16 18:19  ./LICENSE
2026-11-19 16:19  ./src/old_notes.txt
2026-11-19 19:19  ./README.md
2026-11-20 12:19  ./src/utils.py
2026-11-20 22:19  ./src/config.yaml
2026-11-21 15:19  ./logs/app.log
2026-11-21 17:19  ./node_modules/pkg/index.js
2026-11-21 18:09  ./src/app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here they are, oldest at the top. Keep an eye on the readme, changed forty-seven hours ago, and old notes, fifty hours ago. They will matter in a minute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modified in the last 24 hours: -mtime -1
&lt;/h2&gt;

&lt;p&gt;The classic answer is &lt;code&gt;find . -type f -mtime -1&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -type f -mtime -1
./src/app.py
./src/config.yaml
./node_modules/pkg/index.js
./logs/app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-mtime&lt;/code&gt; counts age in whole days. Minus one means: less than one day old. So we get the four files from the last twenty-four hours, including the one inside &lt;code&gt;node_modules&lt;/code&gt;. &lt;code&gt;-type f&lt;/code&gt; keeps only regular files. Without it, directories whose contents changed would show up too.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trap: -mtime 1 and -mtime +1
&lt;/h2&gt;

&lt;p&gt;Now the part that surprises people. What does plain one mean?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -type f -mtime 1
./src/utils.py
./README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plain one means: between one and two days old. Utils, at thirty hours, and the readme, at forty-seven hours. So &lt;code&gt;-mtime +1&lt;/code&gt; must mean older than one day, right? Let's check.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -type f -mtime +1
./src/old_notes.txt
./LICENSE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only old notes and the license. The readme, almost two days old, is missing. That's because &lt;code&gt;find&lt;/code&gt; throws away the fraction of a day before comparing. Forty-seven hours becomes one whole day, and one is not greater than one. In practice, &lt;code&gt;+1&lt;/code&gt; means at least two full days. If you need exact numbers, stop counting in days.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exact times with -mmin
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;-mmin&lt;/code&gt; works the same way, but in minutes. Here is everything changed in the last two hours.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -type f -mmin -120
./src/app.py
./node_modules/pkg/index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And &lt;code&gt;-mmin -1440&lt;/code&gt; is exactly twenty-four hours, with no rounding surprises. For anything older than a day, use &lt;code&gt;-mmin +1440&lt;/code&gt; instead of &lt;code&gt;-mtime +1&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Human-readable dates with -newermt
&lt;/h2&gt;

&lt;p&gt;If doing minute arithmetic isn't your thing, &lt;code&gt;-newermt&lt;/code&gt; accepts a date in plain words.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -type f -newermt &lt;span class="s1"&gt;'6 hours ago'&lt;/span&gt;
./src/app.py
./node_modules/pkg/index.js
./logs/app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also takes a real calendar date. Every file here is newer than January two thousand, so we count eight.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -type f -newermt &lt;span class="s1"&gt;'2000-01-01'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; wc -l
8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Combine it with an exclamation mark, which means not, and you get a time window. Here: changed between two days ago and one day ago.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -type f -newermt &lt;span class="s1"&gt;'2 days ago'&lt;/span&gt; ! -newermt &lt;span class="s1"&gt;'1 day ago'&lt;/span&gt;
./src/utils.py
./README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Skipping folders with -prune
&lt;/h2&gt;

&lt;p&gt;Folders like &lt;code&gt;node_modules&lt;/code&gt; or dot git can flood the results. To skip one, use &lt;code&gt;-prune&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -path ./node_modules -prune -o -type f -mmin -1440
./src/app.py
./src/config.yaml
./node_modules
./logs/app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look closely: the folder itself still shows up in the list. Without an explicit action, &lt;code&gt;find&lt;/code&gt; prints everything that matched, including the pruned path. The fix is to add &lt;code&gt;-print&lt;/code&gt; at the end, so only the right side of the or gets printed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -path ./node_modules -prune -o -type f -mmin -1440 -print
./src/app.py
./src/config.yaml
./logs/app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clean. Three files, and nothing from &lt;code&gt;node_modules&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Show when each file changed
&lt;/h2&gt;

&lt;p&gt;A bare list of names is not very helpful. &lt;code&gt;-printf&lt;/code&gt; can put the modification time in front of each name, and sort puts the newest at the bottom.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -path ./node_modules -prune -o -type f -mmin -1440 -printf &lt;span class="s1"&gt;'%TY-%Tm-%Td %TH:%TM  %p\n'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; sort
2026-11-20 22:19  ./src/config.yaml
2026-11-21 15:19  ./logs/app.log
2026-11-21 18:09  ./src/app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can see the order in which things changed. That is often the real answer to the question: what happened yesterday?&lt;/p&gt;

&lt;h2&gt;
  
  
  Back up today's changes safely
&lt;/h2&gt;

&lt;p&gt;Finally, let's do something with the results: pack them into an archive. &lt;code&gt;-print0&lt;/code&gt; separates names with a null byte, and &lt;code&gt;tar --null -T -&lt;/code&gt; reads that list. Spaces or newlines in file names can't break it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -path ./node_modules -prune -o -type f -mmin -1440 -print0 &lt;span class="o"&gt;|&lt;/span&gt; tar --null -T - -czf /tmp/recent.tgz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's list what went into the archive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ tar -tzvf /tmp/recent.tgz
-rw-r--r-- root/root         5 2026-11-21 18:09 ./src/app.py
-rw-r--r-- root/root         5 2026-11-20 22:19 ./src/config.yaml
-rw-r--r-- root/root         5 2026-11-21 15:19 ./logs/app.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three files, with their original times. If you just want a detailed listing instead, &lt;code&gt;-exec ls -l {} +&lt;/code&gt; does it in one call.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;$ find . -path ./node_modules -prune -o -type f -mmin -1440 -exec ls -l &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt; +
-rw-r--r-- 1 root root 5 Nov 21 15:19 ./logs/app.log
-rw-r--r-- 1 root root 5 Nov 21 18:09 ./src/app.py
-rw-r--r-- 1 root root 5 Nov 20 22:19 ./src/config.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The trap, in one paragraph
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;find -mtime +1&lt;/code&gt; does not mean "older than 24 hours". find drops the fraction of a day before comparing, so a file changed 47 hours ago counts as 1 day, and 1 is not greater than 1. In the demo, &lt;code&gt;README.md&lt;/code&gt; (47 h old) is missing from &lt;code&gt;-mtime +1&lt;/code&gt;. If you need exact numbers, count minutes: &lt;code&gt;-mmin +1440&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick check
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. I want every file changed in the last 24 hours. Do I use -mtime 1 or -mtime -1?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-mtime -1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-mtime 1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-mtime +1&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;
  Answer
  &lt;br&gt;
&lt;strong&gt;&lt;code&gt;-mtime -1&lt;/code&gt;&lt;/strong&gt;: &lt;code&gt;-mtime -1&lt;/code&gt; means less than one day old. Plain one means one to two days old.&lt;br&gt;


&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. README.md is 47 hours old. Will find . -type f -mtime +1 list it?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yes, +1 means older than 24 hours&lt;/li&gt;
&lt;li&gt;No: it needs two full days; use -mmin +1440&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;
  Answer
  &lt;br&gt;
&lt;strong&gt;No: it needs two full days; use -mmin +1440&lt;/strong&gt;: Forty-seven hours rounds down to one day, and one is not greater than one.&lt;br&gt;


&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Recap
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;-mtime -1&lt;/code&gt; or &lt;code&gt;-mmin -1440&lt;/code&gt; for the last day. Remember that &lt;code&gt;-mtime +1&lt;/code&gt; really means two days or more. Use &lt;code&gt;-newermt&lt;/code&gt; for dates in plain words, &lt;code&gt;-prune&lt;/code&gt; plus &lt;code&gt;-print&lt;/code&gt; to skip folders, and &lt;code&gt;-print0&lt;/code&gt; whenever you pass file names to another command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source and reproducible setup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Lesson page with the same quiz (and a video version): &lt;a href="https://shellprovenai.github.io/lekcje/find-changed-24h/" rel="noopener noreferrer"&gt;https://shellprovenai.github.io/lekcje/find-changed-24h/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Commands, demo setup script and full test log: &lt;a href="https://github.com/shellprovenai/terminal-tutorials/tree/main/find-changed-24h" rel="noopener noreferrer"&gt;https://github.com/shellprovenai/terminal-tutorials/tree/main/find-changed-24h&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This article was created with the help of AI and reviewed before publishing. The video on the lesson page uses AI narration and AI-generated robot-and-dog presenters. No sponsors, no affiliate links.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>cli</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
