Shell-script

Concatenate two values in shell scripting

Bash Script to concatenate variables

Use the below code to concate two strings. Example var='My' var="${var}love" echo $var Output Mylove   ..


Pass argument with single quote

Bash script to pass argument with single quote

Pass argument with single quotes If you want to pass argument with single quotes just follow the below step Create file and type as echo $1 Execute file as sh hello.sh "pp'" Output: pp' Pass argument with single quotes sh hello.sh pp\' Execute file as above to pass the argument with single quote.   ..


Comment multiple lines in shell scripting

Bash script

How to comment multiple lines in shell script <<COMMENT1 //Your codes here COMMENT1 (or) <<comment1 //Your codes here comment1 Comment Multiple lines in shell script to comment multiple lines. Comment a particular line or single line If you want to comment the particular line use the # symbol. # Your code This will comment the line your code.   ..


How to comment a line in shell script

Comment a particular line in shell scripting

Comment the particular line If you want to comment the particular line use the # symbol. How to comment multiple lines in shell script <<COMMENT1 //Your codes here COMMENT1 (or) <<comment1 //Your codes here comment1 Comment Multiple lines in shell script to comment multiple lines.   ..


How to increment particular variable in shell script

Shell scripting increment a variable

Increment operation Use the below code to increment the particular variable. gg=0 gg=`expr $gg + 1` echo $gg expr command is used to increment the particular variable.   ..


How to execute shell script

Shell script beginning - Hello World

How to execute shell script Create file with extension as .sh Example: hello.sh echo $0 Execute File as # sh hello.sh Output of the above program is hello.sh   ..


Purge frozen messages in exim mail server

Delete frozen msg in exim server

Purge frozen messages in Exim # exipick -zi | xargs exim -Mrm The above command will delete all the frozen message in exim mail server. This command will be very much helpful when your exim mail server is frozen by mails. Delete frozen mails for i in `mailq | awk '$6 ~  ..


What is linux

Linus operating system

Linux is a free open-source operating system based on Unix. Linus Torvalds originally created Linux with the assistance of developers from around the world. Linux is: => Free => Unix Like => Open Source => Network operating system  ..


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



All rights reserved. © www.w3calculator.com