Category Archives for Shell Scripting
Linux Shell Programs
Bash script to turn off display for specific time
This is a simple bash script to turn off your display for a specified amount of time. (very useful in the case of laptops). The time should be passed as argument to the script (in mins)
Simple backup or mirroring script in bash
Here is a simple bash script for backup/mirroring files and directories. If any one want to contribute or fork this code, you can do it from github page of this script.
Virus Removing Script
Q) There is a set of folders that were affected by virus from a Windows environment. The viruses are in the form of various windows executable formats like .bat, .com and .exe. What separates them from safe windows executables is … Continue reading
Occurence of vowel charaters
# Program to count no of occurence of vowel charaters echo Enter String read string Len=`expr length $string` count=0 i=1 while [ $i -le $Len ] do char=`expr substr $string $i 1` if [ $char = a -o $char = … Continue reading
Number of Characters in a String
# Program to count number of occurance of a character in a string echo "Enter String" read string echo "Enter Character" read char count=0 i=1 len=`expr length $string` echo "String Length : $len" while [ $i -le $len ] do … Continue reading
Students Grade
# Program to find grade,score & modulus of marks using 5 marks of a student echo "Enter 5 Marks" read m1 m2 m3 m4 m5 total=`expr $m1 + $m2 + $m3 + $m4 + $m5` echo "Total Marks = $total" … Continue reading
Fibonacci Series
# Program to find fibonacci numbers within a given range echo Enter Limit read n f1=0 f2=1 echo $f1 echo $f2 n=`expr $n – 2` while [ $n -ne 0 ] do f3=`expr $f1 + $f2` f1=$f2 f2=$f3 echo $f3 … Continue reading
Arithmetic Operations – Menu Driven
# Menu driven program to perform arithmetic operations echo "Enter 2 Numbers" read a b opt=0 while [ $opt -ne 6 ] do echo "Menu 1. Additon 2. Subtraction 3. Multiplication 4. Division 5. Modulus 6. Exit" read opt case … Continue reading
Armstrong Number
# Program to check whether given number is armstrong number or not echo "Enter Number" read num sum=0 item=$num while [ $item -ne 0 ] do rem=`expr $item % 10` cube=`expr $rem \* $rem \* $rem` sum=`expr $sum + $cube` … Continue reading
Shell operations program
# shell program to create a menu which displays # the output for the curresponding options # 1. Current Directory # 2. Todays date # 3. List of users logged in echo Menu echo 1. Current Directory echo 2. Todays … Continue reading

