Hacker News new | past | comments | ask | show | jobs | submit login

> find

> The unix find is a SwissArmyKnife. In PlanNine, the TreeWalking is done by du -- a unix `find . -print` is in PlanNine: `du -a|awk '{print $2}'`

Ah, a clearly much more natural replacement.

EDIT: I got downvoted, but I'm not complaining about it, but rather happy to acknowledge the error of my ways. I cut and pasted what I thought was `du -alawk '{print $2}'`, a mish-mash of 5 unexplained command-line switches, one of them duplicated. (I thought the occurrence of the name `awk` among the switches was just a coincidence.) It wasn't until I noticed the downvote that I realised that what I cut and pasted contained not an `l` switch but a pipe, and was much more simple than what I thought. So, thanks, downvoter!




There's also walk, at least in 9front: http://man.9front.org/1/walk


UNIX: To recursively traverse directories, use find(1)

Plan 9: find(1) is bloat, use du -a | awk '{print $2}'

UNIX: this is complicated to remember and type

Plan 9: oh you can also use walk(1) to recursively traverse directories

UNIX: so... like find(1) ?


Compare the manpages for find and walk.


Much better.


I dunno, I agreed with your comment even comprehending the syntax. Using a -a flag to a disk usage utility seems like an odd way to frame an essential building block. Plan 9 doesn’t have a recursive ls?


I would guess not, given how the article notes later on that "cp" has no recursion flag:

> Imagine how many separate Unix commands have the TreeWalking built into them... RefactorMercilessly.

And suggests the following shell script instead:

  #!/bin/rc
  switch ($#*) {
        case 2 @{ cd $1 && tar c . } | @{ cd $2 && tar x }
        case * echo usage:  dircp from to >[1=2]
  }
Which is horrifying (how would you ever figure out what " $#* " means?), even without the context of the article's own dislike and distrust of system customization:

> The wide variety of superusers allowed each of them to inflict their style guidelines on the structure of the file system... Now where did that @#!$ superuser put gcc or perl or ...

So what's going to happen here? Every time someone wants to list or copy or search or whatever recursively, they're going to have to either write their own potentially buggy variation on this script, or use someone else's. Is there a convention for where they put that script? Every time someone deploys a new Plan9 box, they're probably going to remember that this was a problem before and provide some kind of script like this. Now where did that @#!$ sysadmin put it?

The solution to the repeated code problem is a library, not stripping critical functionality from core system utilities and burdening users with unnecessary complexity. Why is this 40 year old operating system making me so angry!? I should get out more.


> (how would you ever figure out what " $#* " means?)

The same way you figured out what "$@" or "$*" mean on unix: Reading the manual. For that matter, the variable's meaning is the same as on Unix, except with a 'count length of list' operator in there.

Because the plan 9 shell has proper lists, integrated in nicely. Which means that the script above will work even if the arguments have spaces in the filenames.

> Now where did that @#!$ sysadmin put it?

Doesn't matter, I bound it in to my /bin. All binaries are in /bin after you're done setting up your namespace.


> (how would you ever figure out what " $#* " means?)

It's in the manual.

> Now where did that @#!$ sysadmin put it?

The point of Plan 9 is that you don't rely on the sysadmin to put things places for you. You'd mount your home filesystem from wherever it lives and everything would be back to where you expect it. You could even mount /bin from whatever machine you wanted.

Plan 9 does not work in pieces. It only works if you're all-in, which is the reason I don't use it. But when you're all-in, it's very nice. None of the things you're objecting to turn out to be problems in practice. The problems in practice come from not having a c++ compiler or a web browser.


> You could even mount /bin from whatever machine you wanted.

Neat! Now my system is completely unusable if another computer is down or unreachable!

And to think people around here bad-mouth cloud computing.


The fact this got downvoted without discussion must prove it completely discredits Plan 9.


It has more to do with nobody getting paid to teach you about systems engineering. Some search engine keywords to get you started are "distributed systems fault tolerance".


That's utterly irrelevant to my point, but thanks for playing.


`du`, `ls -r` and `find` are all tools which recursively walk and stat directory trees. In that light, it can make sense to pick just one.


I'm with you. The mantra is "do one thing and do it well"

So why is du being generalised to a file system walker?




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

Search: