top | item 462244

A Unix Utility You Should Know About: Pipe Viewer

201 points| pkrumins | 17 years ago |catonmat.net | reply

63 comments

order
[+] aston|17 years ago|reply
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.
[+] raamdev|17 years ago|reply
Thanks! I've been using a tool called pstree for the same thing (I didn't even realize ps had such a feature). It looks like the ps utility on OS X doesn't support --forest though, so pstree is still useful there.

http://freshmeat.net/projects/pstree/

[+] palish|17 years ago|reply
--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".

[+] ivank|17 years ago|reply
htop can also do this.
[+] pkrumins|17 years ago|reply
ask hacker news: what other utilities do you know that others don't? :)
[+] yan|17 years ago|reply
A short list of what I like and use:

the command 'tee': let's you see what is happening at an intermediate stage of a pipeline (I originally thought your blog post would be about tee)

the -S flag to objdump: If you're trying to learn how compilers work or assembly, the '-S' flag to objdumb is absolutely beautiful. If you compile a binary with debugging symbols (-g in gcc), 'objdump -S binary' will intersperse the assembly with the original code, letting you see what each line compiled into.

I use 'pushd' and 'popd' bash builtins. It lets you remember current directories and have a stack of locations that you've been. Very valuable when you're jumping around a large source tree.

Even though not a command, I usually follow ls by "-ltr". That arranges it such that the most recently modified file is on the bottom. Very easy to see what files were modified.

"du -sk * | sort -rn" for a nice listing of directory sizes.

Pressing "esc, ." (That's the Esc key, followed by a period. Not together) in bash would insert the previous command's argument. i.e.:

  bash# ls /some/really/long/path/to/a/huge/file.c
  bash# vi [esc, .]    # <-- that would insert the path
  bash# vi $_          # <-- same effect
'tree' is nice to picture a directory hierarchy.
[+] jsrn|17 years ago|reply
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.
[+] pwk|17 years ago|reply
Oh, and of course netcat (nc). Indispensable for debugging anything TCP/IP based.

  echo -n 'GET / HTTP/1.0\r\n\r\n' | nc news.ycombinator.com 80
Of course there are more specific tools for specific protocols, like curl or wget for http, but nc is the swiss army knife.
[+] gcv|17 years ago|reply
I was happy to discover rlwrap. Not every REPL or utility-with-its-own-prompt out there supports readline by default.
[+] pwk|17 years ago|reply
I find xargs handy, it lets you use the output of one command as arguments for another command. As an example, I have a little alias that I use to grep through my ruby/rails source trees:

  alias gr 'find . -name \*.rb -o -name \*.rhtml -o -name \*.erb -o -name \*.rjs | xargs egrep \!*'
(backticks can be used similarly, but can run into command line length limits)
[+] jacquesm|17 years ago|reply
not really a utility but a very handy one liner to check if someone is being annoying on a http server:

tail -1000 logfile | cut -d ' ' -f 1 | sort | uniq -c | sort -n

Bots should stand out in the last couple of lines and have a linecount that is substantially higher than a normal user.

[+] migpwr|17 years ago|reply
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|17 years ago|reply
You could create an alias for it, like

    alias eta='pv'
[+] cliffy|17 years ago|reply
Is there an equivalent utility for Windows?
[+] newt0311|17 years ago|reply
Wouldn't windows have to have a usable shell first?
[+] ralph|17 years ago|reply
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|17 years ago|reply
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|17 years ago|reply
Easy!

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