Color output from ls – based on file type

2010-02-04 1 min read Bash Linux

Threre are certain default variables which control the color of the output from the ls command, so we will talk about them today.

The first one is to get the color output from the ”ls” command. We will look at the various ways to do this:

First is to use this with default colors:

ls –color=auto

Now this will use the default colors which might not go with your liking 🙂 So if you want to change the colors you can use the variable called LS_COLORS.

Continue reading

Bash styling(themeing), the stylist way.

2010-02-04 1 min read Bash

For last couple of days, I have been looking for solutions to make stlying my bash easier. So, first a screenshot of the effort:

<img class="size-full wp-image-703" title="bash style" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/a.jpg" alt="bash style" width="511" height="332" />

I was looking for the simplest solutions to do this. So, I installed two packages to make my life easier :  bashstyle and fortune.

sudo yum install fortune\*

For bash-style you can download the source files <a href="http://www.nanolx.org/bashstyle-ng/" target="_blank">here. Download the file, then do the following:

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

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

change the terminal title dynamically in X11

2010-01-09 1 min read Bash GNOME Linux

I was actually looking for this for quite sometime. Some years back in my bashrc was the proper setting for setting the terminal title when I did a cd, and I had completely forgotten how to do it. So today I searched quite a few commands the environment variables for doing the same and found it again.

Here it is (Just put this in your bashrc or bash_profile):

export PROMPT_COMMAND=&#8217;echo -ne &#8221;\033]0;`pwd`&#8221;; echo -ne &#8221;\007&#8221;&#8217;

Continue reading

shell — one liner to selectively change case

2010-01-07 2 min read Bash

Today I had a hard time, I had a herculian task of converting the case of file to upper case. Well that&#8217;s not difficult :), I know. What made it difficult was the fact that not the whole file had to be converted but only selective lines containing the work important. Okay now that too is not so difficult, I thought. But again the file size was huge, it had some 9 million lines. So, I just thought of trying my skills of shell programming (dont have much of it anyway). So here&#8217;s what I did:

Continue reading

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
Older posts Newer posts