<filelist.sh> to list all the files under given directory
cd $1
for i in *
do
echo $i
done
below will generate three section, only in first dir, only second dir, in both dir
sh filelist.sh dir1 > dir1file
sh filelist.sh dir2 > dir2file
echo "Those in dir1 but not dir2:"`comm -23 dir1file dir2file`
echo "Those in dir2 but not dir1:"`comm -13 dir1file dir2file`
echo "Those in both dir1 and dir2:"`comm -12 dir1file dir2file`
rm dir1file dir2file
What are you talking about? You posted example folder1, folder2 so the answers were provided accordingly. What is stopping you from putting the commands in a script, say "compare.sh":
rikxik, i have not the command dircmp on mac os x...
i have tried this
#!/bin/bash
var="$(ls -1 /Users/$USER/Desktop/source/ | sed 's/ /_/g')"
var1="$(ls -1 /Users/$USER/Desktop/destination/ | sed 's/ /_/g')"
var3="$var $var1"
for file in $var3
do
if [ "$var" != "$var1" ]
then
echo $file
fi
done
but i only want the file wich is not common on the 2 folders...