Scripting for Inventory

Hi,

I am getting all the scripts in my unix box through ls and pasting them in a xls for the Inventory Purpose.

Right now I am doing it manually I am going manually in each directory and doing a ls > temp.txt and pasting this out put in xls manually.

Is there any way to automate this ..if I run some script in my root directory it should get the folder path , folder name and the script in that folder.

As I said I am doing it manually I don't know how to get started on this..pls tell me some logic for doing this.

Regards,
Deepti

ls can list recursively

ls -1R

But if you need csv format for Excel then example:

#!/usr/bin/ksh
# or bash or dash or ...
# ls2

# directories
dirs=$(find . -type d | sed "s/^.\///")

nowdir=$PWD
# filelist / dir
echo "$dirs" | while read dir
do
        cd "$nowdir/$dir"
        files=$(find . -type f | sed "s/^.\///")
        echo "$files" | while read file
        do
                echo "$dir;$file"
        done
done

Then

chmod a+rx ls2
./ls2 > mylist.csv

---------- Post updated at 07:58 PM ---------- Previous update was at 07:06 PM ----------

Or you can make XML format which is also usable into Excel.

# directories
xmlout()
{
cat <<EOF
<File>
  <Dir>$1</Dir>
  <Filename>$2</Filename>
</File>
EOF
}


#MAIN
dirs=$(find . -type d | sed "s/^.\///")

# XML header
cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata">
EOF

nowdir=$PWD
# filelist / dir
echo "$dirs" | while read dir
do
        cd "$nowdir/$dir"
        files=$(find . -type f | sed "s/^.\///")
        echo "$files" | while read file
        do
                xmlout "$dir" "$file"
        done
done
echo "</dataroot>"