unix - Basename command in shell script -


i trying run following part of application start script:

for file in $template_folder/*     filename='basename $file'     echo "processing $filename"      if [ -f "$conf_folder/$filename" ]             echo "using existing $filename"     else         echo "creating $filename template $file"         cp $file $conf_folder     fi done 

but output is:

processing basename $file creating basename $file template ../conf/templates/conf-test/log4j.xml 

the basename command not evaluated , printed out.

when run command prompt works fine.

bash version:

bash -version gnu bash, version 3.00.16(1)-release (sparc-sun-solaris2.10) copyright (c) 2004 free software foundation, inc. 

can see doing wrong?

thanks!

since system has bash, , script works bash, first change line #1 of script #!/bin/sh #!/bin/bash.

then change line:

filename='basename $file' 

to this:

filename=`basename $file` 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -