bash – using the vi mode more effectively.

2013-11-22 1 min read bash
Vi blogging bundle (Photo credit: pedro mg) You can first set the bash mode to vi. This will enable some vim like features to bash. So, add this to .bashrc : set -o vi Once, you have done that then its time to get more out of the vi mode. First, check some things and set some interesting stuff. #Display all the bindings : bind -P #Copy the current bindings and use it in inputrc: bind -p |grep -v self-insert>~/. Continue reading

Check all vim colorschemes for minor issues

2013-10-10 2 min read bash Vim Tips
Here is script that checks all the colorschemes in the current directory and corrects them if possible (Processing of the file is done with simple commands like sed, grep) Checks that the color_name is same as Filename Here is the script: #!/bin/bash - #=============================================================================== # # FILE: check_colors.sh # # USAGE: ./check_colors.sh # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), # REVISION: --- #=============================================================================== cd ~/. Continue reading

dnsmasq not starting from NetworkManager with SELinux enabled.

2013-03-16 1 min read Fedora Learning Linux
OpenWrt – Dnsmasq (Photo credit: magicfab) Some time back I posted on dnsmasq starting from Network Manager and how to setup dnsmasq. Now, couple of days back , I setup dnsmasq in NetworkManager but was astonished to see that there was no dnsmasq running. I checked with dig and saw that there was no response from localhost for dns queries. Checked “ps -eaf|grep dns” and found that there was no dnsmasq running. Continue reading

Disable a few cores when you want to save power.

2012-12-28 2 min read bash Fedora Linux
If you have a lot of CPU power and working on battery. If you do not need that much of power and would like to rather save some battery power by disabling some cpus then you can use the below script. This script disables cpus from 4 to 7. You can change the number in the for loop. You would need the sudo to be setup or remove sudo and run the script as root. 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

Rekursive Grep on Solaris or AIX Systems without GNU egrep -r funcionality

2011-12-16 1 min read Learning Solaris
If you work regularly on a Solaris or systems which do not have the “-r” (recursive grep) for grep, then you know what a lifesaver this command can be. Here is one from command line fu: find . -type f -exec awk '/linux/ { printf "%s %s: %s\n", FILENAME, NR, $0; }' {} \; The benefit of using awk here is that you can print the line number also 🙂 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
Older posts Newer posts