asked in Software by (8.9k points)
0 like 0 dislike
10 views

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
answered by (8.9k points)

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

dir=$(pwd)

Function:

function mark {
    export $1=`pwd`;
}

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

dir=$PWD

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.

Related questions

0 like 0 dislike
1 answer 16 views
0 like 0 dislike
1 answer 12 views
0 like 0 dislike
1 answer 12 views
0 like 0 dislike
1 answer 15 views
0 like 0 dislike
1 answer 17 views
0 like 0 dislike
1 answer 31 views
0 like 0 dislike
1 answer 41 views
...