I have a bash that reads a directory and tries to cat a file called "test" in each. "test" only exists in the directory called "IOEAdmin" please disregard the other folders in the screenshot.
Here is the bash script
#!/bin/bash
function deploy() {
WD="$(pwd)"
if [[ "$1" = "all" ]]
then
for dir in webapps/* ; do
if [[ "$dir" == *"IOE"* ]]
then
"cat $WD/$dir/test"
# "rm -r -f $WD/$dir"
# projectName=$(echo $dir| cut -d'/' -f 2)
# "cp -r $WD/ioe_production/$projectName $WD/$dir"
fi
done
fi
}
deploy $1
it returns
[tomcat@llsrchwebqa3 tomcat]$ sh deploy.sh all
deploy.sh: line 15: cat /services/tomcat/ioe/tomcat/webapps/IOEAdmin/test: No such file or directory
I then immediately copy the path from the error and run cat on it
[tomcat@llsrchwebqa3 tomcat]$ cat /services/tomcat/ioe/tomcat/webapps/IOEAdmin/test
hello world
[tomcat@llsrchwebqa3 tomcat]$
Here's the entire sequence (ignore the other projects besides IOEAdmin)
[tomcat@llsrchwebqa3 tomcat]$ sh deploy.sh all
all
deploy.sh
/services/tomcat/ioe/tomcat
webapps/IOEAdmin
deploy.sh: line 15: cat /services/tomcat/ioe/tomcat/webapps/IOEAdmin/test: No such file or directory
webapps/IOEPermissions
deploy.sh: line 15: cat /services/tomcat/ioe/tomcat/webapps/IOEPermissions/test: No such file or directory
webapps/IOEReview
deploy.sh: line 15: cat /services/tomcat/ioe/tomcat/webapps/IOEReview/test: No such file or directory
webapps/IOETime
deploy.sh: line 15: cat /services/tomcat/ioe/tomcat/webapps/IOETime/test: No such file or directory
[tomcat@llsrchwebqa3 tomcat]$ cat /services/tomcat/ioe/tomcat/webapps/IOEAdmin/test
hello world
[tomcat@llsrchwebqa3 tomcat]$
"test" was created in linux so I don't think it's a CRLF/LF end of file issue.
Why can't my bash script execute commands like cat, cp, and rm on the "test" file?