Shell-script

Find recent earthquakes in bay area

To see today's earthquake

lynx --width=200 --dump 'http://quake.usgs.gov/recenteqs/Maps/San_Francisco_eqs.htm' | sed -ne '/MAG.*/,/^References/{;s/\[[0-9][0-9]*\]//;1,/h:m:s/d;/Back to map/,$d;/^$/d;/^[ \t][ \t]*[3-9]\.[0-9][0-9]*[ \t][ \t]*/p; }' | sort -k1nr To see only earthquakes for today, add another pipe to egrep "`date '+%Y/%m/%d'`"   ..

How to list all authors of a particular git project

Git project log

You can list all the authors of a particular git project using any one of the below two command's. # git log --format='%aN' | sort -u This should work even if the output format changes. You can also use the below command # git shortlog -s | cut -c8- List everyone who committed  ..

Overloading unix system until crash

This is a fork bomb

WARNING!! This command can produce to crash the unix system where you execute it. What this command do is to generate a lot of threads (so in practice => process) until the system is overloaded, and to recover it, it is needed a reboot of the machine. # echo &&  ..

How to convert hexadecimal to decimal

Command to convert hexadecimal to decimal

Linux command to convert hexadecimal to decimal numbers. # printf "%d\n" \0x64 Linux command to convert hexadecimal to decimal numbers.  ..

How to change directory using shell scripting

Bash or ksh script to change a directory

To change directory in a shell script use "cd" command. echo "Enter the directory name:" read dirname cd $dirname Enter the absolute path to change the directory.   ..

How to read user input from keyboard

Bash scripting read user input

To read the user input you have to use the keyword "read" without quotes. echo "What is your name:" read name echo "Welcome $name" Copy the above shell script and place it in a file called myshell.sh [w3cal@localhost]# sh myshell.sh Enter file name: Jack welcome Jack The  ..

Bash scripting to kill mysql locked process

Kill mysql Locked connection by user name

The below bash script will help you to kill all the mysql locked connection of a specific user. for i in `mysqladmin -h x.x.x.x --user=root -pXXXX processlist | grep <username>| grep <Locked>| awk {'print $2'}` do mysqladmin -h x.x.x.x --user=root -pXXX kill $i; done; substitute the username and process accordingly.   ..

To change directory using bash scripting

Read input and change directory

The unix command used to change a directory is "cd" command. This is a simple bash script to change the directory. echo "Enter the directory name:" read fname cd $fname Above command will change the current working directory to the given directory name.  ..

How to comment multiple lines in shell program

Comment a line in shell scripting

Shell script can be commented by using #. Adding the # symbol at the beginning of the line will comment the entire line. # this will comment a single line To comment multiple lines use #!/bin/bash echo "Say From your heart" #Never Lie <<COMMENT1   ..

Previous 1 2 3

Tech Bluff