Rusty Wright wrote:
I love shell script hacks so my /etc/init.d/tomcat script has the
following in the upper part where it's setting variables:
TOMCAT_HOME=`grep ^tomcat /etc/passwd | sed -e
's/.*:.*:.*:.*:.*:\(.*\):.*/\1/'`
You love shell scripts, but don't seem to love regexp's.
export CATALINA_BASE=${TOMCAT_HOME}
Perhaps instead of .* I could have used [^:]*
Yes. That alone will probably make you regexp about 10,000 times
faster. As first written, the first ".*" will match everything to the
end of the string, but then fail to find the next ":". So it will
backtrack one character and try again.
When it has found the last ":", it will fail to match with the next
".*", so it will backtrack.
And so on...
I don't think 10,000 does it justice. ;-)
I also don't think you want to escape the ().
On the other hand, I think "cut" might be your friend here.
grep "^tomcat" /etc/passwd | cut -d: -f 6
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org