Live data from Hacker News

Unix Commands I Wish I’d Discovered Years Earlier

spin.atomicobject.com

241–250 of 259 posts

Re: Unix Commands I Wish I’d Discovered Years Earlier

#241
post #217

Earlier quoted context omitted.

You should do a screencast of such infinitely useful classics as tac , tsort , and sl . (Actually, I have found use for those first two on occasion. ;)

tsort is one of my favorites, mostly because it's totally pointless until you need it and then it works exactly right . I love it.

Wow. I just read the man page for tsort and I am none the wiser.

  tsort takes a list of pairs of node names representing directed arcs in a 
  graph and prints the nodes in topologi-cal order on standard output. 
It's not often I understand nothing on a man page. But this time, I'm stumped!

Re: Unix Commands I Wish I’d Discovered Years Earlier

#242

Command line globbing! For the uninitiated: Let's say my pwd is `/home/projects` and i want to edit `/home/projects/a_huge_sprawling_app/940j_394/lol/flight_controller.rb` `vim **/flight_controller.rb` opens our flight_controller.rb straight away. In terms of effort, this allows you to basically omit a `find -name` when you're in a rush to edit some damn file where the hell is it again damn we need to reevaluate this…

[deleted]

Re: Unix Commands I Wish I’d Discovered Years Earlier

#243
post #217

Earlier quoted context omitted.

tsort is one of my favorites, mostly because it's totally pointless until you need it and then it works exactly right . I love it.

Wow. I just read the man page for tsort and I am none the wiser. tsort takes a list of pairs of node names representing directed arcs in a graph and prints the nodes in topologi-cal order on standard output. It's not often I understand nothing on a man page. But this time, I'm stumped!

http://en.wikipedia.org/wiki/Topological_sorting

Re: Unix Commands I Wish I’d Discovered Years Earlier

#244
post #217

Earlier quoted context omitted.

tsort is one of my favorites, mostly because it's totally pointless until you need it and then it works exactly right . I love it.

Wow. I just read the man page for tsort and I am none the wiser. tsort takes a list of pairs of node names representing directed arcs in a graph and prints the nodes in topologi-cal order on standard output. It's not often I understand nothing on a man page. But this time, I'm stumped!

Say you have a set of tasks you need to do, and some of those depend on others. Now, you want to perform those tasks in order. The question then becomes: in which order? That's the problem that tsort (1) solves.

It's a way to do some of what make does without having to write a Makefile. 99.9% of the time, it never comes up, but when it does, it is very, very handy to be able to this in a shell pipeline. HTH.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#246
One little known, but very handy tip:

At any password prompt, if you knowingly mis-keyed your password, rather than pressing return, getting the "your an idiot" message (often after an annoying 1 - 2 second delay), and having to retype the command, you can actually press ctrl-U, which is the "Clear the line" bash command, and start over typing your password again.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#247
post #131

xargs. Can't tell you how many times I wrote quickie C programs and awk scripts to do what xargs does. http://sidvind.com/wiki/Xargs_by_example

And find, that's a nice alternative to xargs when your args are a huge set of files.

You can also use parallel instead of xargs when files are huge.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#249
post #222

Earlier quoted context omitted.

Yup, cool use of named pipes.

Named pipes are filesystem objects you create with mkfifo. What's in use here is more widely known as “process substitution”.

Which works by creating two named pipes and feeding them to diff and pumping your processes data into them. Process substitution is built on named pipes, they are the enabling mechanism that makes it work. Try this in a terminal:

  echo 
And you'll see the anonymous named pipe created by the subshell and passed to echo.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#250

Unix and Common Lisp are similar in many ways: 1. Both are operating systems 2. Both are conceptually simple. 3. There is always nice command that does what you want but you somehow forget it. I can't believe that Common Lisp has just 900+ symbols but I routinely forget some of them when programming.

Indeed! Apropos is our friend.

Or if apropos isn't on your system, man -k does the same thing.

... I think it works when apropos isn't installed. Possibly it just calls out to it.

Post reply on HN