TREESCAN(1p)

πŸ’– TREESCAN πŸ’–

okay bestie, listen β€” this one is a Perl user-contributed situation, and it's genuinely iconic. treescan scans directory trees, lists dirs and files, stats, syncs and greps. it's giving "one tool, five jobs, zero complaints" ✨


πŸ¦‹ NAME πŸ¦‹

treescan β€” scan directory trees, list dirs/files, stat, sync, grep. that's the whole flex. no cap. 🌸


🌈 SYNOPSIS 🌈

treescan [OPTION...] [PATH...]

   -q, --quiet    do not print list of files/directories
   -0, --print0   use null character instead of newline to separate names
   -s, --stat     call stat on every entry, to get stat data into cache
   -d, --dirs     only list dirs
   -f, --files    only list files
   -p, --progress regularly print progress to stderr
       --sync     open/fsync/close every entry
   -g, --grep=RE  only list files that match the given perl RegEx

like, look at that. one command, all the vibes. OPTION... then PATH..., done. πŸ’…


✨ DESCRIPTION ✨

the treescan command scans directories and their contents, recursively. like, all the way down, no skipping. 🫢

by default it lists all files and directories β€” and bestie, note that directories get a trailing / so you can tell them apart at a glance. but that's just the default behavior, because it can optionally do a bunch of other things too. main character versatility. πŸ‘‘

oh and super important: if you don't give it any paths, it just uses "." β€” the current directory. so treescan with zero args is literally just "show me everything right here." πŸ™ˆ


πŸŽ€ OPTIONS πŸŽ€

  • -q, --quiet β€” by default, treescan prints the full paths of every directory or file it finds. this option turns filename printing completely off. why would you want that? because sometimes you're only here for the side effects, bestie β€” like pulling stat data into memory. no output, all vibes. πŸ’œ
  • -0, --print0 β€” instead of newlines, it slaps a null character after each filename. this is the move when you're piping the result into other programs, because it dodges all the quoting drama (for example, GNU grep, xargs and so on all have options to deal with this). filenames with spaces and weird characters? not a problem, we don't know her. 🌈
  • -s, --stat β€” normally treescan uses heuristics to avoid most stat calls, which is literally what makes it so fast. this option forces it to stat every single file. πŸ”₯

this is only useful for the side effect of pulling the stat data into the cache. if your disk cache is big enough, it'll be filled with file meta data once treescan is done, which can speed up subsequent commands considerably. and often you can run treescan in parallel with other directory-scanning programs to speed them up. it's a supportive bestie, we love to see it. 🫢

  • -d, --dirs β€” only lists directories, not file paths. perfect when you just want a quick list of directories and their subdirectories. directories only, files can stay home. ✨
  • -f, --files β€” only lists files, not directories. this is the one when you want to operate on all the files in a hierarchy and the directories would only get in the way. respectfully, dirs, not today. πŸ’…
  • -p, --progress β€” regularly prints some progress info to standard error. this is so useful for long running tasks, because you actually get to see something happening instead of staring at a blank terminal wondering if it's alive. and since it goes to standard error, you can still pipe the output of treescan into other programs like nothing happened. genius behavior tbh. 🌸
  • --sync β€” this option makes sure all the files/dirs in a tree are sync'ed to disk. for example, this could be useful after unpacking an archive, so you're sure the files actually hit the disk before you delete the archive file itself. don't delete the source before the copy is safe, bestie, that's the whole lesson. 😭
  • -g, --grep=RE β€” applies a perl regular expression (see the perlre manpage) to all paths that would normally be printed, and only prints the matching paths. it's grep but make it treescan. πŸ”

the regular expression uses an /s (single line) modifier by default, so newlines are matched by ".". iykyk. πŸ’€


πŸ‘‘ AUTHOR πŸ‘‘

Marc Lehmann <schmorp@schmorp.de>

http://home.schmorp.de/


okay that's the whole page, bestie. go scan something. πŸ¦‹

this was perl v5.42.3, brought to you on 2026-08-20 β€” from the TREESCAN(1p) era of the perl documentation, and yes, it ate. periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from