Ehh, What The Hell

Filed Under Ubuntu 

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!)

christer@007:~$ 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

I post tutorials very regularly on this site. You may want to consider subscribing to the RSS feed. Or if you'd prefer these tips sent to your inbox you can use Email Subscriptions.

Related Posts

Random Posts

-->

Comments

6 Responses to “Ehh, What The Hell”

  1. Wolfger on April 10th, 2008 12:59 pm

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

  2. Tormod on April 10th, 2008 3:06 pm

    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.

  3. Christer Edwards on April 10th, 2008 8:55 pm

    @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.

  4. Leonardo on April 13th, 2008 5:00 pm

    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 :)

  5. Scott Paul Robertson on April 15th, 2008 3:37 pm

    So I agree with using $() on principle, but as far as I can tell it doesn’t actually work in this command.

  6. mlissner on April 17th, 2008 1:10 am

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

Leave a Reply




    OSCON


    OSCON 2008

    Subscribe to the RSS feed!


    subscribe to the ubuntu tutorials RSS feed

    Polls


  • Regarding the Ads on Ubuntu Tutorials...

    View Results

    Loading ... Loading ...

  • Blogroll

  • Ads by Google