How can I get the directory where a Bash script is located from within the script itself

0 votes

How do I get the path of the directory in which a Bash script is located, inside that script?

I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash script is located, so I can operate on the files in that directory, like so:

$ ./application

Jun 21, 2022 in Linux Administration by Korak
• 5,820 points
260 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
0 answers

How can I convert a series of images to a PDF from the command line on linux?

I have a scanning server I wrote ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,670 points
274 views
0 votes
1 answer

How do I check if a directory exists in a Bash shell script?

To check if a directory exists in ...READ MORE

answered Jun 7, 2022 in Linux Administration by Korak
• 5,820 points
1,476 views
0 votes
0 answers

How can I invoke both BASH and CSH shells in a same script

In the same script, I want to ...READ MORE

Jun 21, 2022 in Linux Administration by Korak
• 5,820 points
309 views
0 votes
0 answers

How do I run a program with commandline arguments using GDB within a Bash script?

When running a program on GDB, usually, ...READ MORE

Jun 21, 2022 in Linux Administration by Korak
• 5,820 points
541 views
0 votes
0 answers

How to detect the OS from a Bash script?

I would like to keep my .bashrc and .bash_login files in ...READ MORE

Jun 21, 2022 in Linux Administration by Korak
• 5,820 points
373 views
0 votes
0 answers

How to detect the OS from a Bash script?

I would like to keep my .bashrc and .bash_login files in ...READ MORE

Jun 22, 2022 in Linux Administration by Korak
• 5,820 points
338 views
0 votes
1 answer
0 votes
1 answer

How to find the first field from a file in Bash Shell?

Hi@akhtar, You can extract text from a file. ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,440 points
835 views
0 votes
0 answers

How can I monitor the thread count of a process on linux?

I would like to monitor the number ...READ MORE

Apr 21, 2022 in Linux Administration by Edureka
• 13,670 points
218 views
0 votes
0 answers

How can I delete a user in linux when the system says its currently used in a process

I am trying to delete a user ...READ MORE

Apr 26, 2022 in Linux Administration by Edureka
• 13,670 points
315 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP