Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 8181  / 1 Year ago, fri, may 19, 2023, 9:08:14

I have a nice little bash alias in my .bashrc folder that allows me to start Tomcat running without having to cd into the folder first, e.g.



alias startTomcat="cd ~/apache-tomcat-7.0.34/bin/ && ./startup.sh"


However when I run startTomcatin a terminal, I'm booted out of the folder I started in, and now my terminal's residing in ~/apache-tomcat-7.0.34/bin/. This is expected behaviour, of course, but what I'd like to do is run the command without winding up in a different folder.



Can I either save the original location, then return to it in my .bashrc file, or alternatively run startup.sh without cding out of the original folder?



Thanks!!


More From » bash

 Answers
6

You can use the absolute path for startup.sh without to cd in the folder where is located::



alias startTomcat="~/apache-tomcat-7.0.34/bin/startup.sh"


Or, you can use cd - which will return you to the directory where you were last time:



alias startTomcat="cd ~/apache-tomcat-7.0.34/bin/ && ./startup.sh && cd -"

[#29626] Saturday, May 20, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
olltea

Total Points: 238
Total Questions: 115
Total Answers: 107

Location: Moldova
Member since Tue, Feb 7, 2023
1 Year ago
;