Pat Gunn (dachte) wrote,
Pat Gunn
dachte

  • Location:
  • Music:

Unix Without Files

Inspired by a conversation on IRC, more of a brain dump than a coherent essay:

There's a distinction between "everything is a file" and "everything is a stream of bytes", even as they both are part of the design philosophy of Unix. Could we have a Unixlike experience without a local filesystem? To understand this, focus on command invocations that don't explicitly reference filenames and what they can do. We might joke that this is taking commands like bzcat/zcat to their logical extreme :) We can ignore implicit reference to filenames because we can imagine a shell that would have all our commands as inernals, properly handling pipes between these commands by spawning multiple copies of itself or through some other, more alien means, without any true external commands. I have some scripts I regularly use in my unix environment that talk to a local PostgreSQL database and extract data, either statically or based on arguments I provide. In the past I've also had this for some remote database connections, as well as things that reformat the output of things like netstat for me. With some of this data, I process it further before looking at it, e.g. through sort/cut/grep, through pipes, usually landing in either less or in "vim -". I could chain this through another pipe to something that would go through the details of stashing it back into a database (either as a BLOB or in a formatted way by parsing it) or some other storage system. I don't think it feels particularly un-unixy to imagine the following:


$ dbls -db docs -category books -author "Pier%" -created _gt_ "3 Dec 2005" -return id,name
6778 | Phaze Doubt
6779 | Blue Adept
6885 | Unicorn Point
$ `$LASTCMD` | dbcut -f1 | dbgrep -i -db docs -field data "Nyssa" -return data | docfilter -out pdf | evince

Of course, there may be all sorts of better syntaxes with varying power. The main point is that I think the Unix flavour and much of the power of Unix is more strongly tied to the idea of pipelines and the "bag of bytes" mentality than to everything living in files.

Subscribe

  • Still alive

    Been feeling a bit nostalgic. Not about to return to LiveJournal - their new ownership is unfortunate, but I wanted to briefly note what's been up…

  • Unplugging LJ

    It's about time I pulled the plug on the LJ version of my blog: 1) I'm much more active on G+ than I am with general blogging. I post many times a…

  • Mutual Trust

    I don't know which should be considered more remarkable: That a cat should trust a member of a far larger and stronger species that it can't…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments