Get the latest tech news

Pruning some things out with (GNU) find options


Suppose that you need to scan your filesystems and pass some files with specific names, ownerships, or whatever, except that you want to exclude scanning under /tmp and /var/tmp (as illustrative examples). Perhaps also you're feeding the file names to a shell script, especially in a pipeline, which means that you'd like to screen out directory and file names that have (common) problem characters in them, like spaces.

Because we want to use a character class to match whitespace, we need to use one of the regular expression types that include this, so: Unfortunately it's sometimes what we turn to because our other options involve things like writing programs that consume and filter NUL-terminated file paths. PS: One of the little annoyances of Unix for system administrators is that so many things in a stock Unix environment fall apart the moment people start putting odd characters in file names, unless you take extreme care and use unusual tools.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Options

Options

Photo of things

things

Photo of GNU

GNU

Related news:

News photo

Game of the Week: exploring the other things that make a Metroidvania great

News photo

Embracer boss admits "long list" of things he'd have done differently, as embattled company splits into three

News photo

Hades 2 is kicking things off with a special weapon: familiarity