• Android

    Android is an operating system based on the Linux kernel, and designed primarily for touch screen mobile devices such as smart phones and tablet computers. Android is a Linux-based software system, and similar to Linux, is free and open source software. This means that other companies can use the Android operating developed by Google and use it in their mobile devices.Android gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.

  • Welcome to Bashguru

    Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. It's functionality list is quite similar to that of UNIX and become very popular over the last several years. Our Basic motive is to provide latest information about Linux Operating system.

  • Python Programming

    Python is a comparatively simple programming language, compared to c++. Although some of the benefits of c++ are abstracted away in python, they are replaced with an overall easier to learn language with many “intuitive” features. For this reason it is common and recommended by most professionals that people new to programming start with python.

  • Perl Programming

    Perl is an open-source, general-purpose interpreted programming language. Used often for CGI, Perl is also used for graphics programming, system administration, network programming, finance, bioinformatics, and other applications. The Perl languages borrow features from other programming languages including C, shell scripting (sh), AWK, and sed. They provide powerful text processing facilities without the arbitrary data-length limits of many contemporary UNIX command line tools, facilitating easy manipulation of text files.

  • Android

    Android is an operating system based on the Linux kernel, and designed primarily for touch screen mobile devices such as smart phones and tablet computers. Android is a Linux-based software system, and similar to Linux, is free and open source software. This means that other companies can use the Android operating developed by Google and use it in their mobile devices.Android gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.

  • Welcome to Bashguru

    Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. It's functionality list is quite similar to that of UNIX and become very popular over the last several years. Our Basic motive is to provide latest information about Linux Operating system.

Monday, December 28, 2009

Posted by venu k
3 comments | 10:46 PM
This is the upgrade version of the ddcopy_progress.sh script posted on 2nd November.#!/bin/bash## SCRIPT: ddcopy.sh# PURPOSE: Copies files and shows the progress of copying.##............................USAGE...........................# This script copies only files not directories# ddcopy <Source filename or Path> <Destination filename or Path># ddcopy <Source filename or Path> <Destination Directory or Path>###################################################################...

Tuesday, November 24, 2009

Posted by venu k
7 comments | 2:20 PM
Hello friends, I have watched this video on Youtube.I hope you will also enjoy it.Original link for this video is http://www.youtube.com/watch?v=bYcF_xX2...

Tuesday, November 17, 2009

Posted by venu k
9 comments | 11:58 AM
#!/bin/bash# SCRIPT: primenumbers.sh# USAGE : ./primenumbers.sh <Range Value># or;# ./ primenumbers.sh <Start Range Value> <End Range Value># PURPOSE: Produce prime numbers within a range lmit.############### DEFINE FUNCTIONS HERE ##############Usage(){ echo "********BAD ARGUMENTS**********" echo "Usage: scriptname <Range Value >" echo " or " echo "Usage: scriptname <Start Range Value> <End Range Value>" exit 1}################# ARGUMENTS...
Posted by venu k
21 comments | 8:46 AM
Reposted on 18-06-2011 and Method 4 was deleted.The simplest primality test is as follows: Given an input number n,check whether any integer m from 2 to n − 1 divides n. If n is divisi-ble by any m then n is composite, otherwise it is prime.Method 1:Now most people who write finding prime number in shell script(Almostin all languages) may start with something simple, like:#!/bin/bash# SCRIPT: prime1.sh# USAGE : ./prime1.sh# PURPOSE: Finds whether given number is prime or not#####################################################################echo...

Sunday, November 15, 2009

Posted by venu k
126 comments | 1:19 AM
Like UNIX commands, shell scripts also accept arguments from the command line.They can, therefore, run non interactively and be used with redirection andpipelines.Positional Parameters:Arguments are passed from the command line into a shell program using thepositional parameters $1 through to $9. Each parameter corresponds to theposition of the argument on the command line.The first argument is read by the shell into the parameter $1, The secondargument into $2, and so on. After $9, the arguments must be enclosed inbrackets, for example, ${10},...

Thursday, November 12, 2009

Posted by venu k
5 comments | 1:17 AM
Method 1:#!/bin/bash## SCRIPT : leapyear.sh# PURPOSE: Checks whether given year is a leap year or not# USAGE : sh leapyear.sh # If Year value not supplied, it takes current year as default## This script based on, One year has the length of 365 days, 5 hours,# 48 minutes and 47 seconds. Because this is rather non-functional,# a normal year has been given 365 days and a leap year 366 days.#################################################################### DEFINE FUNCTIONS HERE #########################################################################Leap(){#...

Monday, November 2, 2009

Posted by venu k
2 comments | 4:21 AM
This script not replaces cp command. This is a sample script for practice purpose.I am going to develop more elegant script, which fulfil most of the cp command strengths.I will post complete version of the script as soon as possible,I shall really appreciate all comments and suggestions to improve this script.#!/bin/bash## SCRIPT: ddcopy_progress.sh# PURPOSE: This script is used to watch progress of copying.## Note: I am using destination file...

Sunday, November 1, 2009

Posted by venu k
7 comments | 11:56 AM
#!/bin/bash## SCRIPT: bigfile.sh# PURPOSE: This script is used to create a text file that# has a specified number of lines that is specified# on the command line.#usage(){echo "............USAGE ERROR............"echo "USAGE: $0 <number_of_lines_to_create>"}# Argument Checkingif [ $# -ne 1 ] # Looking for exactly one parameterthen usage # Usage error was made exit 1 # Exit on a usage errorfi# Define files and variables hereLINE_LENGTH=80 # Number of...

Tuesday, October 27, 2009

Posted by venu k
23 comments | 8:41 AM
Method 1:#!/bin/bash# fact1# Finding factorial of a given number#echo "Enter a number"read numfact=1n=$numwhile [ $num -ge 1 ]do fact=`echo $fact \* $num|bc` # You can use bellow commands also # fact=$((fact*num)) # fact=`expr $fact \* $num` # But maximum integer value that bash can handle is # 9223372036854775807. # An operation that takes a variable outside these # limits will give an erroneous result. To solve this # problem store numbers as strings and use bc for math. let num--doneecho "factorial of $n is $fact"Method...

Monday, October 26, 2009

Posted by venu k
1 comment | 9:50 AM
#!/bin/bash# Usage: forloop2.sh or forloop2.sh number# Example using for loop# Prints following format# *# * *# * * *# * *# *n=${1-10} # If command line argument not supplied default is 10t=`expr $((2*$n - 1 ))`a=$nb=$(($a+1))for (( i=1 ; i<=$n ;i++ ))do echo -e -n "\033[47m" a=$(($b-1)) b=$a k=1for (( j=1 ; j<=$t ; j++ )) do if [ $j -eq $a ] then echo -e "\033[43m * \033[47m\c" if [ $k...

Saturday, October 10, 2009

Posted by venu k
8 comments | 9:55 AM
Defining the Shell TypeTo make a bash script crate a new file with a starting line like:#!/bin/bash It is important that the path to the bash is proper and first two characters must be “#!” . The shell from which you are starting the script will find this line and hand the wholescript over to bash. Without this line the script would be interpreted by the same type of shell as the one, from whichit was started.But since the syntax is different for all shells, it is necessary to define the shell with that line.Some typical interpreters...

Wednesday, October 7, 2009

Posted by venu k
4 comments | 8:19 AM
#!/bin/bash # Usage: script.sh number# A for loop example produces following output## *# * *# * * *# * * * *# * * * * *#Method1c=1n=$1echo -e "\033[47m\c" #colourizing outputfor ((row=1;row<=n;row++))do for ((i=row;i<n;i++)) do echo -n ' ' done for ((k=1;k<=c;k++)) do if [ $((k%2)) -eq 0 ] then ...
Posted by venu k
2 comments | 7:58 AM
A 'for loop' is a bash programming language statement which allows code to be repeatedlyexecuted. A for loop is classified as an iteration statement i.e. it is the repetition of a processwithin a bash script.For example, you can run UNIX command or task 5 times or read and process list of files usinga for loop. A for loop can be used at a shell prompt or within a shell script itself.for loop syntaxNumeric ranges for syntax is as follows:for VARIABLE in 1 2 3 4 5 .. Ndo command1 command2 commandNdoneExamples:#!/bin/bahfor i in 1 2...
Posted by venu k
3 comments | 6:10 AM
#!/bin/bash # Usage: scriptname argument # Here argument is height of pyramid # Output would be pyramid pattern of stars # 0 * # 1 *** # 2 ***** # 3 ******* # 4 ********* # 5 *********** # 6 ************* # . *************** # . ***************** # . ******************* # ...
Posted by venu k
6 comments | 5:35 AM
#!/bin/bash# Usage: scriptname argument# Here argument is height of pyramid# Output would be pyramid pattern of stars# 0 *# 1 ***# 2 *****# 3 *******# 4 *********# 5 ***********# 6 *************# . ***************# . *****************# . *******************# n-1 *********************#...

Tuesday, September 22, 2009

Posted by venu k
1 comment | 10:22 PM
#!/bin/bash# sys_monitor2.sh# Usage: sys_monitor2.sh [-u|-d|-f (D/M)| -c number | -m number]# Sample system monitor script using options# Tested under Fedora 9Invalidoptions(){ echo "Usage: `basename $0` [OPTIONS]" echo "OPTIONS:" echo -e "\t -d for display today's date" echo -e "\t -u for Logged in users list" echo -e "\t -f ARG for Disk and Memory Statistics" echo -e "\t (ARG=D for disk statistics; ARG=M for memory statistics)" echo -e "\t -c ARG for Top CPU consuming process" echo -e "\t (ARG=10 means top 10...
Posted by venu k
12 comments | 9:31 PM
#!/bin/bash# sys_monitor.sh# Sample system monitor script using menu# Tested under Fedora 9## Create the following menu and clear the screen each time it appears#clearecho -e "\033[1m `uname -or` Monitor script\033[0m"items=" 1.Date 2.Current Users 3.Disk Statistics 4.Memory Statistics 5.Top 10 Memory consuming process 6.Top 10 CPU consuming process 7.Exit"exit_function(){ clear exit}#function enter is used to go back to menu and clear screenenter(){ ans= echo "" echo -e "Do you want to continue(y/n):\c"...

Saturday, September 19, 2009

Posted by venu k
78 comments | 10:33 AM
#!/bin/bash# isuserloggedin.sh# Usage: isuserloggedin.sh username# Shell script which checks after every one minute whether a user has logged in# or not# You can also run script in background using & then foreground it to view resultif [ $# -ne 1 ]then echo "You supplied wrong arguments" echo "usage : `basename $0` username"exit 1fiisuserexist(){grep -w "$1" /etc/passwd > /dev/nullif [ $? -eq 1 ]then echo "$1 is not a valid user"exit 1fi}isuserexist $1time=0while truedo# you can replace following two statements with# if `who|grep...
Posted by venu k
12 comments | 10:11 AM
#!/bin/bash# validuser.sh# Usage: validuser.sh username# Script to check whether suplied user has an account in your systemif [ $# -ne 1 ]then echo "You supplied wrong arguments" echo "Usage : `basename $0` user_name"exit 1fi#grep -w "$1" /etc/passwd > /dev/nullgrep -w "^$1" /etc/passwd > /dev/nullif [ $? -eq 1 ]then echo "$1 is not a valid user"else echo "$1 is a valid user"fi# Using greps -q option you can simplify and faster your script# if `grep -qw "^$1" /etc/passwd`# greps -q option prints nothing just returns exit status 0...

Wednesday, September 2, 2009

Posted by venu k
8 comments | 1:25 PM
There are various ways to read input within the time limit in shell script. I am posting 4 methods here.First three are direct methods. Final one implemented with some logic, just for practice only.Method 1: #!/bin/bash # timedinput1.sh: prompts times out at five seconds. # Using read command timelimit=5 echo -e " You have $timelimit seconds\n Enter your name quickly: \c" name="" read -t $timelimit name #read -t $timelimit name <&1 # for bash versions bellow 3.x if [ ! -z "$name" ] then ...

Sunday, August 23, 2009

Posted by venu k
9 comments | 7:10 AM
Hard link: Hard link refers to "The specific location of physical data".Hard Link is a mirror copy of the original file.Hard links share the same inode.Any changes made to the original or Hard linked file will reflect the other.Even if you delete any one of the files, nothing will happen to the other hard links.But soft link which points to deleted hard link become a dangling soft link.You can't link a directory even within the same file system.Hard...