Hacker News new | past | comments | ask | show | jobs | submit login
Rawhide – (rh) find files using pretty C expressions (raf.org)
61 points by g0xA52A2A on Sept 26, 2022 | hide | past | favorite | 14 comments



This sounds like an awesome tool, and the "hacker spirit" of it really speaks to me.

It's really fitting to have a supremely technical and focused tool like this be described with things like "pretty C expressions" and (my favorite) "it's like find(1), but more fun to use", because obviously writing low-level C-like expressions to match against files is fun, most of all. Love it.

Also some of the examples are truly powerful, and at least I was not aware of any tool that could do things like this:

    # Find executable files that are larger than 10KiB, and have not been executed in the last 24 hours:
    anyx && sz > 10K && atime < ago(day)

    # Find regular files with multiple hard links
    f && nlink > 1

    # Find symlinks whose ultimate targets are on a different filesystem:
    texists && tdev != dev
Examples all cherry-picked from the manual page, and I picked the most terse version, more readable/explanatory versions using fewer built-ins are also available.

Many of the examples feel liks "I would never need that"-territory, until you do and then it's like impossible unless you write your own specialized tool to do it, or reach for this. Very cool!


Looking at the last line:

   Authors: 1990 Ken Stauffer, 2022 raf <raf@raf.org>
Has this been around since 1990?

I’m bummed I didn’t know about it. The variety of output options is amazing.


It was around in 1990. Then as far as I know, it disappeared, until I stumbled across it in my old comp.cources.unix file in an old archive tarball, and had to bring it back to life and up to date.


Thank you very much for doing that!

Do you happen to know why it was called rawhide? I'm very curious.


Sorry, I don't.


But I like to think it refers to making the raw C API available on the command line.


Yes, it has been. I've used it in the past (end of 90s) but I don't remember what for. Might've been some abacadabra like dd and fdisk on non-x86 or *BSD? I'm not sure. I actually forgot the name of this application, but now that I see it, I immediately recognized it.

Btw, its not related to RedHat or Fedora Rawhide.


Holy shit, that's a blast from the past.

Hello Robert if you're reading this.

Others, have a look at libslack too.


What did he do to rh? I suppose just adding json support, and 64bit off_t support.

Ah, I see: https://github.com/raforg/rawhide/commits/main A bit more cleanup and handy aliases also.


I was the original author. Heh, heh -- I'm still alive. I just glanced at the code and it looks like a wonderful rewrite. I couldn't see any of my original gross code. Not only that, they massively added to the functionality. It's really a totally new thing. I just had to chime in here to thank raf for seeing something cool in the original and making a great piece of software. -- Ken


Is the “rawhide” name somehow based on the “Ride 'em in, cut 'em out, … Move 'em on, head 'em up“ idea from the Rawhide theme song, applied to files instead of cattle?


The CHANGELOG file shows the changes for v3.0: https://github.com/raforg/rawhide/blob/main/CHANGELOG

The were many changes. The search criteria language evolved. More search criteria were added. It now can do everything GNU find(1) can do (except filesystem type names), as well as searching by all/more of the inode/stat metadata, and access control lists ("POSIX", NFSv4, and macOS ones), and extended attributes (names and values), and (soon in v3.1) Linux ext2-style file attributes (like immutable and append-only). And it's thoroughly documented and tested. And the standard library of search terms wasn't there before. And of course, it now handles regular expressions, but only perl-compatible ones, because they are the most fun. The output options were expanded a lot based on GNU find (-printf) and GNU ls and json.

But it is almost completely backwards-compatible! Except that "NOW" is now called "now", and the -r option is slightly different (it was -M1, now it's -m1 -M1), and it no longer defaults to reading search criteria from stdin.

The original rawhide v2 is at https://github.com/rafarc/rawhide if you'd like to see it.


This looks very handy, and maps closely to something I use Perl for, but that requires more boilerplate.

But, if you find yourself wanting something like this, and don't want to install anything new... Here's something close in Perl that uses File::stat (this ships with Perl):

  find . -print | perl -MFile::stat -nE 'chomp;$s=stat($_);$s->nlink > 1 && say'


Also see `find2perl`

I use that occasionally when coding up hairy `find` invocations.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: