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

Wednesday, June 4, 2008

Posted by venu k
7 comments | 6:11 AM
#!/bin/bash
# Traverse a directory using depth first traversal technique
# Usage $0 directorypath
# otherwise it takes current working directory as directory path

depth()
{
#Do a small depth checking how deep into the tree we are
k=0
while [ $k -lt $1 ]
do
echo -n " "
let k++
#or use k=`expr $k + 1`
done
}

traverse()
{
# Traverse a directory

ls "$1"while read i
do
depth $2
if [ -d "$1/$i" ]
then
echo Directory: $1/$i
traverse "$1/$i" `expr $2 + 1`
# Calling this as a subshell means that when the called
# function changes directory, it will not affect our
# current working directory
# If you call this in current shell it gives the error
# bash: traverse: No such file or directory after changing
# the current directory
else

echo File: $1/$i
fi
done
}

# $1 is directory path

if [ -z "$1" ]
then
# Here we are giving '0' is the current depth of direcory
traverse . 0
else
traverse $1 0
fi

7 comments:

  1. Small correction at line
    ls "$1"while read i

    I think the above line should be
    ls "$1" | while read i

    ReplyDelete
  2. Your yield looks totally right to me given that opendir and readdir emphasize through directory sections in the request in which they show up which is for the most part dictated by the request in which the records were made.While hunting down a best essay writing service I have discovered number of writing service. It is getting confounded which one I need to pick. I selected one of the best from that through essay writing service reviews, In particular I should to shoot for a best service that giving quality papers.

    ReplyDelete
  3. It is some kind of language which is used to make the application. In simple words, it is something like a code which is very useful and helps the people with australianwritings. This is so wonderful information to the students who need this help and I found your site is good and informative.

    ReplyDelete
  4. Your blogs programming knowledge is good. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    uipath training in bangalore

    ReplyDelete
  5. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site
    digital marketing training in chennai

    ReplyDelete
  6. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site. Digital marketing training in Bangalore

    ReplyDelete