UNIX & Linux programs
Program in UNIX rename which will rename files in the current directory according to the following arguments: suffix to be replaced
Write the BASH shell script rename which will rename files in the current directory according to the following arguments: suffix to be replaced
The script should rename each matching regular file or symbolic link in the current directory by replacing the file name suffix with replacement suffix. For example:
rename a.txt a.text
will rename the file a.txt to a.text. However, no overwriting of existing files nor renaming of the special directories . and .. is allowed.
for i in `ls *.txt`
do
fname=`basename $i txt`
mv $i ${fname}text
done