Ehh, What The Hell

By | 2008/04/10

I figure I’d join the band-wagon too, but I’ll use *readable* $() vs the absolutely unreadable-horrible-habit `.  (Yes, that is a `.  What?  You can’t tell what character that is?  Yeah, neither can I when you use it in your code!  Its a back-tick and shouldn’t be used because its unreadable!)

[email protected]:~$ history | awk $({a[$2]++ } END{for(i in a){print a[i] " " i}})|sort -rn|head
96 ls
87 vim
70 cd
60 bzr
25 sudo
16 rm
14 ssh
13 grep
13 cat
11 scp

6 thoughts on “Ehh, What The Hell

  1. Wolfger

    Actually, I’m having no problem telling what that is. You need a better font. 🙂

    Reply
  2. Tormod

    Erm… you got that all wrong. $() is equivalent to a pair of backticks (`). awk scripts are often enclosed in single quotes (‘) to keep the shell from substituting for instance the $’s used in the awk syntax.

    Reply
  3. Christer Edwards Post author

    @Tormod – I’m familiar with awk using single-quotes as part of its normal operation, but the shell history code that I copy-pasted from the previous sites was using back-ticks, which I replaced with $().

    The reason I actually did it was that a copy-paste from the blog didn’t work as the back-ticks were improperly translated between blog and shell.

    Reply
  4. Leonardo

    Personally, I have no problem telling the character apart, and since I usually edit scripts in Vim, the syntax highlighting finishes making it a non-problem.

    In fact, given I think $() clutters things up even more.
    But that’s just me. We seem to dissent, but at least we would agree that readability is an important quest 🙂

    Reply
  5. mlissner

    A more important thing to note is you can nest $(). You cannot nest back ticks.

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.