
A Unix Utility You Should Know About: Pipe Viewer - pkrumins
http://www.catonmat.net/blog/unix-utilities-pipe-viewer/
======
aston
I just learned about the --forest switch for ps. If you use it, you'll get a
tree representing all of the parent and child processes running rather than
just a straight up list.

~~~
palish
\--forest? Seriously?

Metaphors are sometimes confusing. Call it what it is. "Reflection" should
have been called "type information", for example, and "--forest" should have
been called "--nested".

~~~
yan
A process tree is known to almost everyone who uses Unix. A forest is, in my
opinion, a good name for a collection of trees.

Reflection is the ability of something to introspect. The term "self-
reflection" dates back to 1652[1], so why change it? "Type information" is
inaccurate because reflection can mean more than just getting information
about types, like interfacing with the runtime or getting information about
the language implementation.

I don't think concepts should be misnamed at the expense of accuracy.

[1] <http://www.merriam-webster.com/dictionary/self-reflection>

~~~
palish
_The term "self-reflection" dates back to 1652, so why change it?_

I'm saying it shouldn't have been used in the first place. It's an awkward,
confusing metaphor. Programs aren't "reflecting", because "self-reflection" is
something that only a sentient creature can perform. Programs currently have
no concept of "self". I'd say "reflection" is less accurate than "type
information", which covers at least 95% of use cases, if not more.

 _I don't think concepts should be misnamed at the expense of accuracy._

Neither do I. Also, all else being equal, less metaphors are better.

------
pkrumins
ask hacker news: what other utilities do you know that others don't? :)

~~~
jsrn
mmv (moves multiple files based on a simple pattern replacement language).
Example:

    
    
        mmv "*.mp3" "old_#1.mp3"
    

prefixes all files in the current directory ending with .mp3 with 'old_'.
Btw., the quotes around the arguments are necesssary because mmv uses some of
the same metacharacters as the shell does.

Multiple substitutions are allowed, e.g.:

    
    
        $ mmv "*.*" "#1___#2"
    

renames blub.xyz to blub___xyz.

~~~
nickb
Anyone know where to find a source tarball that compiles under Leopard? All
I've found is a bunch of precompiled Linux RPMs...

~~~
ruby_roo
Update your MacPorts. It was just added:

<http://trac.macports.org/changeset/46335>

------
migpwr
This sounds useful but I don't like the fact that it's named "pv". I've always
associated "pv" with physical volume and lvm... might be a little confusing.

~~~
kaens
You could create an alias for it, like

    
    
        alias eta='pv'

------
akkartik
I made a graphical wrapper a few years ago -- call it from a terminal, but if
you have X it won't munge stderr.<http://akkartik.name/bash.html#pipeview>

------
wmf
For more pipe tricks, check out bidilink:

<http://0pointer.de/lennart/projects/bidilink/>

------
cliffy
Is there an equivalent utility for Windows?

~~~
newt0311
Wouldn't windows have to have a usable shell first?

~~~
gnaritas
It does, it's called cygwin and it's the first thing you install after getting
windows to boot.

~~~
likpok
Cygwin is a bloated piece of crap, especially if you run Vista/Server
200[3-8]. See my other comment about SUA.

~~~
gojomo
How is cygwin worse (more bloated or 'crap') on Vista/Server than other
Windows versions?

~~~
nailer
* It's redundant as there's posh out of the box, which has built in aliases for common Unix commands

* It reimplements common Windows services

* Doesn't separate content from presentation

* Doesn't integrate with other server software

* Lacks the reporting tools posh has - eg, sending a table to Excel.

~~~
gnaritas
Powershell is not a unix, just because it can do some of the same things and
has aliases for some of the commands doesn't make it a drop in replacement.
Cygwin is a drop in replacement that lets me run the same scripts I run on my
Linux boxes, i.e. it is not redundant.

I'll take cygwin over powershell any and every day of the week.

~~~
nailer
I didn't state that Powershell was a Unix. Instead, I implied it's a superior
way to control Windows from a command line, which it is.

Running Linux scripts is a double edged sword: you can use existing scripts,
but they can't access the whole Windows API, are too long due to unnecessary
regex work, and can't report as easily.

~~~
gnaritas
I don't want to control Windows from the command line, I want to control my
own applications, access the file system, and run and manage services.

Of course powershell integrates with Windows better than cygwin, the power of
cygwin is that it makes Windows a usable Unix, which is far more important to
me than controlling Windows.

------
ralph
Sometimes, pv(1) doesn't help. For example, `tar cf - foo | bzip2 -9v
>foo.tar.bz2'. You don't know the size of the data that needs to pass down the
pipe. But I sometimes find watching tar(1) open the files to read is handy;
`strace -e trace=open $(pidof tar)'.

------
Keyframe
anyone have an idea how this might work in tandem with dd, for example dd
if=/dev/urandom of=1GB.bin bs=1M count=1024

~~~
blasdel
Easy!

    
    
      dd if=/dev/urandom bs=1M count=1024 | pv | dd of=1GB.bin

~~~
pkrumins
or simpler:

    
    
        dd if=/dev/urandom bs=1M count=1024 | pv > 1GB.bin

