[Solved] How to create a script by combing two files?

I am trying to generate a csv file for utilization of each project directory. there are 10 filesystem and for each filesystem there are 16 directory.
i was trying to create a script so i created two file. one is filesystem and one is project. so file looks like

cat filesystems

/app1
/app2
/app3
....
....
/app10

cat project

proj1
proj2
....
....
proj16

Now, I want to create a script so that it will check du for /app1/proj1 then /app1/proj2 then /app1/proj3 and so on till /app1/proj16 and O/P will write to out.csv file

After /app1 completes then again it will start for /app2/proj1 then /app2/proj2 and so on and O/P will write to out.csv file in a new line

and finally script will run for /app10/proj1 then /app10/proj2 and so on till /app10/pro16 and O/P will write to out.csv

need yours help

Try :

for i in $(cat filesystems_file); do  

          for j in $(cat project_file); do 
                     echo du -h $i/$j
          done
done

OR

while read filesystems; do 
                 while read project; do 
                              echo du -h $filesystems/$project 
                 done < project_file
done < filesystems_file

if echo is fine then redirect to output file

@Akshay, only the second option wil work if any of the names contain spaces, and only if "$filesystems/$project" is in double quotes..

Hello,

Following may also help.

 
values_check=`paste -d/ first_file_disk second_file_disk`
set -A array_values_check values_check ${values_check}
for i in ${array_values_check[@]}
do
echo "***************************************************"
du $i
echo "***************************************************"
done
 

Where first_file_disk second_file_disk are two files.

Thanks,
R. Singh

Thanks Akshay It worked ..
Need one more help
When I do cat projects|wc -l then i get O/P as 16
Now I want to create a file (say file1) where exact 16 entries should be there with only date value
example -- when I do cat for file1, it should like below

cat file1
2014-01-20
2014-01-20
2014-01-20
........
.......
2014-01-20

Date can be defined as
DATE=`date "+%Y-%m-%d"`

In recent shells, try

for (( i=1; i<=16; i++ )); do echo $DATE >> file1; done

Yes, it worked ..!!
instead of giving value as "16" i just want to give input of cat projects|wc -l
example

DATE=`date "+%Y-%m-%d"`
value=`cat projects|wc -l`
for (( i=1; i<=$value; i++ )); do echo $DATE > File1; done

but it is giving only one entry in file1.

cat file1
2014-01-20

Use double >> to append or use > after the done statement:

.... ; done > File1

Pls compare your code snippet painstakingly with mine...

change to >>file1

# Redirect output to file "filename" overwrite if file is existing
command >filename

# Redirect and append output to file "filename"
command >>filename

Thanks everyone .. this has been resolved.
i was doing silly mistake. I was using "> File1" but it should be ">>File1"