An efficient UNIX shell-script…
Om | Oct 22, 2008 | 0 comments
If you use lot of Unix shellscripts in the VI editor, then here’s an efficient UNIX shell-script to compare two files & delete one of them if they are duplicates… Simple yet pretty handy, just check-up!
if(test $# -eq 2)
then
if(test -f $1 && test -f $2)
then
if(cmp $1 $2)
then
echo “files are same”
echo “$2 deleted”
rm $2
else
echo “files are not same”
fi
else
echo “one of them is not a file”
fi
else
echo “MY COMMAND: enter two file names”
fi
Sounds pretty ordinary, but just check up is that really what you do as well?
And sure thing if have a better way then share it here :)
Related posts:
- Some Unix Tricks
- Learn Unix in 10 minutes
- Linux & Unix Tricks
- 11 Unix Tricks
- Do not run this script, ever!
Filed Under: Linux and Unix
