My homework question given is:
How can you print the path of the current directory (working
directory) and how can you use it as a variable?
The first part of the question is easily answered: By using pwd.
But how can I use the output as a variable?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In bash, you can execute a command and obtain the output using backticks, for example
There is an alternate syntax too, using a dollar sign and brackets –
WORKING_DIRECTORY=$(pwd)