Anji
Anji

Reputation: 73

How to rename the files using bash script

TOMCAT_FILE=/sys/project/apache-tomcat-8.5.47.tar.gz
if [ -e "$TOMCAT_FILE" ]
then
    echo "##############"
    echo ""
    echo "Installing Tomcat"
    tar zxf $TOMCAT_FILE -C /sys/project/
    echo "##############"
    echo "Tomcat Installation completed"
    mv  $TOMCAT_FILE/apache-tomcat-8.5.47
    echo "tomcat source file moved to apache"
    echo "Removing tomcat tar file from the current directory"
    rm -rf $TOMCAT_FILE/apache-tomcat-8.5.47.tar.gz
    echo "tomcat tar file removed"
fi

I have bash script to install tomcat, after installing tomcat tar file, i need rename the tomcat file like this (apache-tomcat-8.5.47 to apache), but when i running the scripts file renaming & deleting is not happened when i am checking my source directory /sys/project/.

Can you please some one suggest me how to achieve this task.

Upvotes: 0

Views: 100

Answers (1)

Chris Maes
Chris Maes

Reputation: 37842

mv $TOMCAT_FILE/apache-tomcat-8.5.47

cannot work since need to specify where you want to move it to, probably something like

mv /sys/project/apache-tomcat-8.5.47 /sys/project/apache

Upvotes: 2

Related Questions