Display the output of a command from the first line until the first instance of a regular expression.

2010-01-04 0 min read Bash Linux
\"Screenshot
Image via Wikipedia

| perl -n -e 'print "$_" if 1 … /«a class="zem_slink freebase/en/regular_expression" title="Regular expression" rel="wikipedia" href="http://en.wikipedia.org/wiki/Regular_expression">regex>/;# This <a class="zem_slink freebase/en/command_line_interface" title="Command-line interface" rel="wikipedia" href="http://en.wikipedia.org/wiki/Command-line_interface">command line will display the output of , from the first line of output, until the first time it sees a <a class="zem_slink freebase/en/pattern_matching" title="Pattern matching" rel="wikipedia" href="http://en.wikipedia.org/wiki/Pattern_matching">pattern matching .

Continue reading

View the newest xkcd comic.

2009-12-07 1 min read Bash Linux

This function displays the latest comic from xkcd.com. One of the best things about xkcd is the title text when you hover over the comic, so this function also displays that after you close the comic.

$ xkcd(){ local f=$(curl -s <a href="http://xkcd.com/">http://xkcd.com/);display $(echo "$f"|grep -Po '(?<=")http://imgs.xkcd.com/comics/[^"]+(png|jpg)');echo "$f"|awk '/<img src="http://imgs.xkcd.com/comics/.?" title=./{gsub(/^.title=.|".?$/,"");print}';}

To get a random xkcd comic, I also use the following:

xkcdrandom(){ local f=$(wget -q <a href="http://dynamic.xkcd.com/comic/random/">http://dynamic.xkcd.com/comic/random/ -O -);display $(echo "$f"|grep -Po '(?<=")http://imgs.xkcd.com/comics/[^"]+(png|jpg)');echo "$f"|awk '/<img src="http://imgs.xkcd.com/comics/.?" title=./{gsub(/^.title=.|".?$/,"");print}';}

Continue reading

Insert a comment on command line for reminder

2009-12-05 1 min read Bash Linux

<a href="http://blog.amit-agarwal.co.in/category/linux/">Bookmark this category
Insert a comment on command line for reminder

$ ls -alh #mycomment

Comments can be used directly on the command line so I can save in the history a brief description of what command does.

* View this command to comment, vote or add to favourites * View all commands by vgagliardi

commandlinefu.com

by David Winterbottom (codeinthehole.com)

URL: <a href="http://feedproxy.google.com/~r/Command-line-fu/~3/_5hXsFUuAwc/insert-a-comment-on-command-line-for-reminder">http://feedproxy.google.com/~r/Command-line-fu/~3/_5hXsFUuAwc/insert-a-comment-on-command-line-for-reminder

bash colors

2009-11-16 0 min read Bash
\"People
Image via Wikipedia

For those of the terminal freaks, color is a bliss. But have you tried all the colors in the terminal. Today someone forwarded me a bash one liner for the same. Not sure where he got this from, anyway here is the one liner for you all:

Continue reading

Get your external IP address

2009-11-04 1 min read Bash Linux

$ echo -e "GET /automation/n09230945.asp HTTP/1.0rnHost: whatismyip.comrn" | nc whatismyip.com 80 | tail -n1

  • <a href="http://www.commandlinefu.com/commands/view/3962/get-your-external-ip-address">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/Marko">View all commands by <a href="http://feeds2.feedburner.com/commands/by/Marko">Marko

<a href="http://www.commandlinefu.com"><img src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/header-logo.jpg" alt="" align="bottom" />

by David Winterbottom (<a href="http://codeinthehole.com">codeinthehole.com)

<a href="http://feedads.g.doubleclick.net/~a/JcVSM9r0yMSf6O0G2eSK5vyQGsU/0/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/JcVSM9r0yMSf6O0G2eSK5vyQGsU/0/di" alt="" align="bottom" />
<a href="http://feedads.g.doubleclick.net/~a/JcVSM9r0yMSf6O0G2eSK5vyQGsU/1/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/JcVSM9r0yMSf6O0G2eSK5vyQGsU/1/di" alt="" align="bottom" />

<img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~r/Command-line-fu/~4/7xln2n56mnk" alt="" width="1" height="1" align="bottom" />

URL: <a href="http://feedproxy.google.com/~r/Command-line-fu/~3/7xln2n56mnk/get-your-external-ip-address">http://feedproxy.google.com/~r/Command-line-fu/~3/7xln2n56mnk/get-your-external-ip-address<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://www.computer-realm.net/how-find-computers-ip/">How to Find Out Your Computer&#8217;s IP (computer-realm.net) <div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/42c8d78f-7105-47fc-9f21-6df9065a21a3/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_e29.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related pretty-attribution">

Continue reading
Older posts Newer posts