15 Linux Bash History Expansion Examples You Should Know

2012-03-02 1 min read bash
Image via Wikipedia Here is a nice link on BASH History Expansion. There are lot of examples in this page and some of them might be quite useful. But here are my list of favourites: !! This is probably the most used one by me. This will repeat the last command. And this works even in conjunction with other commands like sudo !! And the second most used one is : Continue reading

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; Related articles SQL Fiddle (thinkvitamin.com) New Oracle E-Book (arnoldit.com) All about Security – SQL Injection (tkyte.blogspot.com)

glances – Get a glimpse of the whole system

2012-02-21 1 min read Fedora
You would have used top at some point of time. Did you not wish that instead of just the processes it list all the vital statistics of the system as a whole. How good it would be to see the Memory, Net, Processes and Disk usage on the same screen. Well then you should take a look at glances. Here is how it looks: [][1]glances For using this tool, here is what you need to do : Continue reading

BASH Script Performace

2012-01-06 2 min read bash Learning
Today we will look at some bash code snippests and the performance issues. Lets first look at the problem and the implemented solution: Problem: We needed to log the output of the ps command for all the process’s. This was required to be done on per minute basis and the output was required in comma separated files. So, here is what was implemented: pslog=`ps -e -opid,ppid,user,nlwp,pmem,vsz,rss,s,time,stime,pri,nice,pcp:u,args|grep -v PID|sort -r -k 13,13` OLD_IFS=$IFS IFS=$'\n' logarr=( $pslog ) for LOGLINE in ${logarr[@]} do LOGLINE=`echo $LOGLINE|awk '{OFS=" Continue reading

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. Continue reading

Linux hardware details.

2011-11-28 3 min read bash Learning Linux
Here is one of the scripts that I found on the net while searching for something … Note the URL for the script in the Description. #!/bin/bash - #=============================================================================== # # FILE: linux_hw.sh # # USAGE: ./linux_hw.sh # # DESCRIPTION: http://www.howtogeek.com/howto/solaris/get-the-processor-type-on-solaris/ # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), amit.agarwal@roamware.com # COMPANY: Roamware India Pvt Ltd # CREATED: 09/13/2011 03:57:34 PM IST # Last modified: Sun Oct 30, 2011 04:59PM # REVISION: --- #=============================================================================== function linux_hw_CPU { typeset num=0 typeset name=" Continue reading

Cont: Get yourself some more conkyrc files.

2011-10-12 1 min read bash Learning Linux
Last time we got ourselves some conkyrc files from the ubuntu forums. But that scripts gets the files only from the First page of the thread. Lets extend this further and get the script to get all the conkyrc files. There are some 1048 pages in the thread, I am showing pages 1 to 3 but you can change 3 to whatever number you want 🙂 count=0 for i in {1. Continue reading
Older posts Newer posts