Quickly search and replace string with Regular expression in multiple files using perl

2010-01-27 1 min read Linux

for i in *; do perl -p -w -e ’s/a(.*)b.*/d$1e/g’  $i > temp/$i; done

for i in *; do perl -pi -w -e ’s/a(.*)b.*/d$1e/g’  $i ; done

The first one can be used when you want to preserve the original file. The redirection will cause the file with replaced string to be written to the new location in the temp directory. Modify the same according to your needs.

The second can be used to modify the files in-line. Causing overwriting the original file.

Continue reading

grep -v with multiple patterns.

2010-01-25 1 min read Bash Linux

$ sed '/test/{/error|critical|warning/d}' somefile If you wanted to do all in one command, you could go w/ sed instead

  • <a href="http://www.commandlinefu.com/commands/view/3882/grep-v-with-multiple-patterns.">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/pipping">View all commands by <a href="http://feeds2.feedburner.com/commands/by/pipping">pipping

<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/J5B2Z5VTSlqhmd-2YMQ4ndmAu4U/0/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/J5B2Z5VTSlqhmd-2YMQ4ndmAu4U/0/di" alt="" align="bottom" />
<a href="http://feedads.g.doubleclick.net/~a/J5B2Z5VTSlqhmd-2YMQ4ndmAu4U/1/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/J5B2Z5VTSlqhmd-2YMQ4ndmAu4U/1/di" alt="" align="bottom" />

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

URL: <a href="http://feedproxy.google.com/~r/Command-line-fu/~3/LjKzo7FpzDU/grep-v-with-multiple-patterns.">http://feedproxy.google.com/~r/Command-line-fu/~3/LjKzo7FpzDU/grep-v-with-multiple-patterns.<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.seroundtable.com/archives/020935.html">Google&#8217;s &#8221;Show More Results&#8221; Plus Box (seroundtable.com) <li class="zemanta-article-ul-li"><a href="http://www.macworld.com/article/143351/2009/10/netprocesses.html?lsrc=rss_main">See which processes are using the Internet (macworld.com) <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/cc60245b-7397-4d48-83b2-7bfb345ae7a9/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_e20.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related pretty-attribution">

Continue reading

statifier — Dynamic to Static

2010-01-24 2 min read Linux

<a href="http://statifier.sourceforge.net/">Homepage of statifier.

<span style="font-size: xx-small;"><span style="font-size: xx-small;">Statifier create from dynamically linked executables and all it&#8217;s libraries one file.
This file can be copied and run on another machine without need to drag all it&#8217;s libraries.

<span style="font-size: xx-small;"><span style="font-size: xx-small;">Dynamically linked executables are smaller then statically linked.
From the other side dynamically linked executables use shared libraries compiled in PIC (position independend code) which is slower than &#8221;normal&#8221; one.

Continue reading

Short Information about loaded kernel modules

2010-01-24 2 min read Linux

There are couple of ways you can find the information on the <a class="zem_slink" title="Loadable kernel module" rel="wikipedia" href="http://en.wikipedia.org/wiki/Loadable_kernel_module">loadable kernel modules. All these would always involve calling <a class="zem_slink" title="Lsmod" rel="wikipedia" href="http://en.wikipedia.org/wiki/Lsmod">lsmod to get the loaded kernel modules and then calling modinfo to get the info on the loaded modules. I will show you with examples:

$ lsmod
Module                  Size  Used by
cdc_acm                19616  0
vfat                    8744  9
fat                    41836  1 vfat

Continue reading

Seders\’s grab bag – Tutorials

2010-01-24 3 min read Bash Fedora Learning Linux

<a href="http://sed.sourceforge.net/grabbag/tutorials/">http://sed.sourceforge.net/grabbag/tutorials/

<span style="font-size: x-large;"><a href="http://sed.sourceforge.net/grabbag/">seder&#8217;s<a href="http://sed.sourceforge.net/grabbag/"> grab bag

  • <a href="http://sed.sourceforge.net/grabbag/scripts/">scripts

  • <a href="http://sed.sourceforge.net/grabbag/tutorials/">tutorials

  • <a href="http://sed.sourceforge.net/grabbag/seders/">seders

  • <a href="http://sed.sourceforge.net/grabbag/ssed/">ssed

  • <a href="http://sed.sourceforge.net/grabbag/links/">links

  • <a href="http://sed.sourceforge.net/grabbag/tutorials/#intros">Intros

  • <a href="http://sed.sourceforge.net/grabbag/tutorials/#advanced">Advanced

  • <a href="http://sed.sourceforge.net/grabbag/tutorials/#misc">Miscellaneous

<span style="font-size: large;">Sed Tutorials

If you have written anything about sed – whether an introduction, how sed got you out of a real-life situation, or perhaps an advanced technique you&#8217;ve discovered – you may like have your work published here. <a href="mailto:bonzini@gnu.org">Your contribution will be very welcome.

Continue reading

Copy temporary evolution images downloaded for messages

2010-01-21 1 min read Linux Photo

cd ~/.evolution
cd cache
cd http
find . -name &#8221;*.jpg&#8221; -exec cp {} /tmp/newfolder \;

Simple to understand, so no explanation 🙂 <a name="more">

Blog worth mentioning on linux.com

2010-01-21 1 min read Linux

Go to the blog <a href="http://www.linux.com/community/blogs/linux-command-line.html" target="_blank">here. I am specially interested to find out if this is a joke or what? Could not find out, if you do let me know in the comment.

Older posts Newer posts