I have to submit a script for slurm. I should enter the directory path whenever I change the submit script path. for example if I am in folder1 I should write manually:


if I want to use the script in folder2 I should write:


Is there any command to avoid making this change manually?

PS: I know I can use $pwd but I did not find the right way.

1 Answer 1


With $PWD

  • PWD is an environment variable that is updated to contain the current directory,
  • $variable is replaced by the value of variable

This gives:

thescript $PWD

With $(pwd)

  • pwd is a command that prints the current directory
  • $(command) is replaced by the output of command

This gives:

thescript $(pwd)
  • @PRATAP No, as explained, they are two different things.
    – xenoid
    Oct 13, 2019 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.