PDA

View Full Version : AIX unix system script (need help)



Liam Battle
01-30-2002, 11:29 AM
Im writting a script which takes two directories and displays them, then displays the contents which do not match in the two directories.

I tried using the -v command in grep but it does not work properly, ill show you my current code (sorry im new to unix scripting) :

if [ ! $# = 2 ]
then
echo Usage: dircomp dir-name1 dir-name2 ... 1>&2
exit 1
elif [ ! -d $1 ]
then
echo The first argument $1 is not a directory 1>&2
exit 1
elif [ ! -d $2 ]
then
echo the Second argument $2 is not a directory 1>&2
exit 1
else
ls $1 -al > list
ls $2 -al > list2
grep -v -f list list2
rm list
rm list2
exit 0
fi

-----
Thanks in Advance

Salem
01-30-2002, 12:08 PM
Well it's off-topic

read the manual on the comm command

Liam Battle
01-30-2002, 01:54 PM
the comm command surpresses unique lines, i dont want to, i want to show the unique lines between the two files... which are the non matching lines... and the DIFF command which can accomplish this has a problem with it, it will put '<' '>' in front of what i want to change

alex
01-30-2002, 02:34 PM
Hi,

diff --brief directory1 directory2
this suppresses the output of differences in files. Is this what you are looking for? If not, can you give a simple example of the output you want.

alex

Unregistered
02-10-2002, 05:34 PM
check out uniq