cd across parallel directories

2011-03-14 1 min read Bash Linux

A diagram showing the key Unix and Unix-like o...
Image via Wikipedia

Here is a simple and fast way to cd across parallel directory.

  <td>
    <div class="text codecolorer">
      cd ${PWD/test/actual}
    </div>
  </td>
</tr>
1
Enhanced by Zemanta

/bash debugger

2011-02-27 5 min read Bash Linux

In this section we’ll develop a very basic debugger for bash.[10] Most debuggers have numerous sophisticated features that help a programmer in dissecting a program, but just about all of them include the ability to step through a running program, stop it at selected places, and examine the values of variables. These simple features are what we will concentrate on providing in our debugger. Specifically, we’ll provide the ability to:

Continue reading

vino – connect to running GNome session like RDP

2011-02-04 2 min read Fedora Linux

One thing that all of us Linux users have probably missed is connecting to the running GNome session to see what is going on in the running session. This can be quite handy in couple of situations:

  1. Debugging remote sessions – where you do not want a new session, instead want to connect to running session.

  2. Maintaining running session from another PC. If you are running some applications on some Linux box and want to gracefully stop it using some commands other than kill -9 then it is best that you connect to the running session, if you are not using screen.

    Continue reading

Ranking of the most frequently used commands

2011-01-31 2 min read Linux Uncategorized

Lets take a quick look at how to get the most frequently used commands on you shell. So what we need to do is this:

  <td>
    <div class="text codecolorer">
      history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr
    </div>
  </td>
</tr>
1

So, how did we arrive at this and will this always work? No it might not always work. A typical example is where HISTTIMEFORMAT variable is set. In that case, if you check history, you will see that after the number column we have time and date in the specified format, in which case, you will get wrong information from the above command. Anyways, forgetting these special cases, lets go to how we got this command:

Continue reading

shopt causes bash completion to stop working.

2011-01-25 1 min read Bash

Couple of days, I added some scripts to my bash startup and suddenly realized that bash completions stopped working. This is tricky situation in bash to figure out what went wrong. So, I set my foot down to make sure that I find out the culprit. Thus I started with method of elimination. So, I started with nothing in .bashrc and kept adding my stuff in batches, until the said feature was broken. Once that happened I started removing the added ones, one by one, until my completion started working again.

Continue reading

Execute a command with a timeout

2010-12-29 1 min read Bash Learning
Official Ubuntu circle with wordmark. Replace ...
  <dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">
    Image via <a href="http://commons.wikipedia.org/wiki/File:Ubuntu_logo.svg">Wikipedia</a>
  </dd>
</dl>

Execute a command with a timeout

  <td>
    <div class="text codecolorer">
      &nbsp;timelimit -t100 somecommand
    </div>
  </td>
</tr>
1

I found this in Ubuntu repos, and consider it better than timeout.

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

Continue reading
Older posts Newer posts