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

Friday, August 14, 2009

Posted by venu k
2 comments | 11:43 PM
# gcd.sh: greatest common divisor uses Eclidean algorithm
# Usage : gcd.sh num1 num2 num3 .... (any number of arguments)
# The algorithm used to calculate the GCD two integers is known as the Euclidean algorithm.
# Based on Euclidean algorithm this script is written(Recursive method).
# For checking supplied arguments are integers or not check GCD of two numbers code

# Argument check
# Minimum 2 arguments you should to supply

if [ $# -lt "$ARGS" ]
echo "Invalid Arguments"
echo "Usage: $0 first-number second-number"
# Preserve command line argument for future use

function Euclidean()
if [ $2 -eq 0 ]
return $1
Euclidean $2 $(($1%$2)) # calling function recursively
Euclidean $1 $2
# $? returns the exit status of script. This is one method to capture return value of a function

# Shifts command line arguments one step.Now $1 holds second argument

while true
# shift is used to pick up next command line argument to continue iteration
# $# holds total number of arguments.At every shift operation its value decreases one

if [ $# -eq 0 ]
break 2
Euclidean $return $1
echo "GCD of $cmdargs is $return"
exit 0