Wednesday, September 22, 2010

Simple Linux BASH script to swap two filenames

#!/bin/bash
if [ $# -lt 2 ]
then
echo "2 arguments needed."
exit
fi

mv $1 tmp
mv $2 $1
mv tmp $2

echo "Done!"

1 comment:

Param said...

There might be a problem in case 'tmp' already exists in the folder and is useful for some application.