using `!#$’ to referance backward-word

2011-11-03 1 min read Bash Linux

Operating System Tablet Strategy
Image by jeffalldridge via Flickr

Here is something that I found on the commandlinefu

cp /work/host/phone/ui/main.cpp !#$:s/host/target

Ah well…its very interesting and very useful.

Some explanation:

!# – means the current command (similar to !! being the last command)

$ – represents the last parameter

:s – is used for substitution.

Enhanced by Zemanta

bash regular expressions

2011-02-06 1 min read Bash

Here are some quick links on bash regular expressions, pretty good links to bookmark, if you use, regular expressions in bash regularly. I especially like the tldp link at number 3.

http://www.linuxjournal.com/content/bash-regular-expressions
http://www.ibm.com/developerworks/library/l-bash.html
http://tldp.org/LDP/abs/html/parameter-substitution.html#VARMATCH
http://wellington.pm.org/archive/200005/codegen/index9.htm

Enhanced by Zemanta

fork a new process in perl

2011-01-27 1 min read Uncategorized

I was doing something today and found that I require to fork a new process in perl. Now I had never done this earlier, so I did not know how to do this.

First some background :

I was doing some program very similar to http server, where the script accepts some input through a socket and then processes the same. In doing so I was seeing that the script was taking some time in processing the input and thus was not processing the second request until the first one was completed. Simple solution, fork the process.

Continue reading

cURL – Tutorial

2010-09-15 1 min read Bash Fedora Linux

Here are linkw to two nice tutorials on curl and how to use curl to login before we try to fetch a page. Hope you find them useful.
http://curl.haxx.se/docs/httpscripting.html

http://www.youtube.com/watch?v=XcgQUsorF_8

http://scriptasy.com/php_11/tutorial-curl-login_44.html

Enhanced by Zemanta

Making your subjects more prominent and stand out in the photos with gimp.

2010-09-10 1 min read Photo

Lets first take a picture that we want to modify. We have done the corrections in the photo that are required like the curves, <a class="zem_slink" title="Colorfulness" rel="wikipedia" href="http://en.wikipedia.org/wiki/Colorfulness">saturation and others. So, here is the photo after the modification. Now we will make the modification to make photo de-saturated other than the subject of interest.

<a href="http://blog.amit-agarwal.co.in/wp-content/gallery/home/DSC_0018.jpg"><img src="http://blog.amit-agarwal.co.in/wp-content/gallery/home/DSC_0018.jpg" alt="DSC_0018" />

Okay, now fire up gimp and open the <a class="zem_slink" title="Image" rel="wikipedia" href="http://en.wikipedia.org/wiki/Image">image in gimp.Once the image is open, on the left bottom of the image, you will see a square. Click on the square and the whole image will become red. Now, select eraser tool and erase the color from the subject of interest.

Continue reading

Linux command to repeat a string n times - Super User

2010-07-20 1 min read Bash Linux

I was working on something and needed to output the string n times. I have required this even to print a line with &#8217;-&#8217; or &#8217;=&#8217; but this time I badly wanted it in bash. So I searched google and found this:

printf &#8221;Amit Agarwal%.0s&#8221; {1..5}

Explanations and other examples: <a href="http://superuser.com/questions/86340/linux-command-to-repeat-a-string-n-times">http://superuser.com/questions/86340/linux-command-to-repeat-a-string-n-times<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.rateitall.com/i-3177235-flat-rate-us-terminations.aspx">1 reviews of Flat-Rate US Terminations (rateitall.com) <li class="zemanta-article-ul-li"><a href="http://www.brighthub.com/computing/linux/articles/75743.aspx">Top Linux GUI (brighthub.com) <li class="zemanta-article-ul-li"><a href="http://www.gnu.org/software/emacs/tour/">A guided tour of Emacs (gnu.org) <div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/zemified_e6.png" alt="Enhanced by Zemanta" /><span class="zem-script more-related pretty-attribution">

Continue reading
Older posts Newer posts