Shortcut to run current command with sudo in bash

2012-09-20 1 min read Fedora Linux

For me, I mostly forget to add “sudo” to the command until the time I am actually supposed to run it. Also sometimes, on some systems, bash completion does not work as expected with “sudo”. With these in mind, I wanted something such that when I have completed the command, I could insert sudo in the begining of the command without much ado. So, finally this is what I came up with in my “~/.inputrc” file. Note: If you don’t have this file, then simply create this file.

Continue reading

gqlplus – sqlplus with readline (tab completion)

2012-08-03 1 min read Database

Tab completion is something which is missing in the sqlplus and if you have lot of tables with long names or lot of columns then it is sufficiently  difficult to type them 🙂

Here is a solution for this problem. Download and install gqlplus. gqlplus is a replcement for sqlplus which supports completion for commands/tablenames and column names. Quite useful.

Oracle SQL*Plus
Oracle SQL*Plus (Photo credit: Manuel Cernuda)
Enhanced by Zemanta

Oracle Select the top 5 queries

2012-02-27 1 min read Database

Here are one sql script that I found some time back. This will be listing the top 5 SQL queries in Oracle.

SET linesize 300
SET PAGESIZE 200
select *
from
(select sql_text,
        sql_id,
        elapsed_time,
        cpu_time,
        user_io_wait_time
from    sys.v_$sqlarea
order by 5 desc)
where rownum < 6;
quit;
Enhanced by Zemanta

Backup of files in the directory.

2011-12-01 2 min read Bash Learning Linux

I was working on some scripts and the changes that I was making in the scripts was very dynamic, which I did want to keep backing up in the version control system. But for the peace of my mind, I wanted to keep a copy of the scripts, whenever it was in working state.

Since I had multiple files, so it would make more sense to have a script that could copy all the files in the current directory to “old” directory without over-writing the existing files. So, I wrote a script that would postfix the files with a number. With this approach, finally what I had was the following:

Continue reading

Faster blog with stats removed

2011-06-18 1 min read Wordpress

I was thinking of removing the statpress plugin for quite some time now, but did not have a good alternative. Today finally I managed to do this as I had few hours to spare. Now that this is done, you should not be getting the database error that some of you on IE were getting and also should have a nicer experience in terms of page load time.

Enhanced by Zemanta

mysql output to an array for easy parsing.

2011-05-11 2 min read Bash Database

 

Today I was looking for some way to put the output of the mysql output in an array in a bash script. Quick google search yeilded to results something like this:

 

  <td>
    <div class="text codecolorer">
      output=$(mysql -e "select * from table")
    </div>
  </td>
</tr>
1

The problem with the above approach is that all the words go into separate index. So if you have a line that has space then that is split into multiple index’s. Not good…

Continue reading

Make any command read line enabled (on *nix)

2010-11-25 1 min read Bash Fedora Linux

Make any command read line enabled (on *nix)

  <td>
    <div class="text codecolorer">
      rlwrap sqlite3 database.db
    </div>
  </td>
</tr>
1

Enable readline even if the command line application is not using it.

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

commandlinefu.com

by David Winterbottom (codeinthehole.com)

URL: http://feedproxy.google.com/~r/Command-line-fu/~3/mKEgYoyHCMA/make-any-command-read-line-enabled-on-nix

Enhanced by Zemanta
Older posts