Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with unix script

Status
Not open for further replies.

dianne001

Programmer
Mar 1, 2002
38
US
I am trying to write a unix script that will compare source directories. first I create three files using the ls -la for each source directory. then I want to sepearate the directory names to a file and the files to a file.

then I want to compare the directory files. and then compare the file files.

This is what I have so far. I do not know how to write a loop.

#!/bin/sh
#
#
###############################################################
echo "Starting Compare Process"
###############################################################
testsrc=/src/testsrc
devsrc=/src/devsrc
prodsrc=/src/prodsrc
tmpdir=/src/tmp
rm $tmpdir/testlist1.lst
rm $tmpdir/prodlist1.lst
rm $tmpdir/devlist1.lst
cd $testsrc
ls -la > $tmpdir/testlist1.lst
echo 'created testlist1'
cd $devsrc
ls -la > $tmpdir/devlist1.lst
echo 'created devlist1'
cd $prodsrc
ls -la > $tmpdir/prodlist1.lst
echo 'created prodlist1'


Please help!!!
 


dear friend
if you want to create directory list in same directory
then use the following command :
ls -lF |grep '/' > mfile

if you want to create directory list in sub directory
then use the following command :
ls -lFR |grep '/' > mfile

if you want to create file list in same directory
then use the following command :
ls -lF | grep -v '/' > mfile
 
Perhaps you don't have to write a loop, just use diff ....

diff devlist1.lst testlist1.lst
diff testlist1.lst prodlist1.lst

If you have it (and you can make sense of it's report), use diff3 ....

diff3 devlist1.lst testlist1.lst prodlist1.lst

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top