in Software by (12.3k points)
0 like 0 dislike

How I can to dynamically get path to current directory in bash? How to save current directory in variable using bash? What I'm trying to do is find the current working directory and save it into a variable. How do I save the current directory in variable using bash script? How can I get the current working directory?

bash current dir variable

1 Answer

0 like 0 dislike
by (12.3k points)

This saves the absolute path of current working directory to the variable dir:



function mark {
    export $1=`pwd`;

Current working directory variable, i.e. full path:


Print full path:

echo $dir

Your answer

Try to answer the question as detailed as possible.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.