7

What is the difference between cwd and pwd?

I've tried googling it, and one of the answers mentioned that depending on some factor (which I sadly do not remember), the implementation (the code I'm assuming) is not the same? I don't suppose this is like the difference between print('x') vs return str(x) (to use a Python analogy)?

1 Answer 1

13
  • cwd: current working directory (a concept, state, or value)
  • pwd: print working directory (a command)

Part of the confusion may be that in some shells $PWD is actually the current working directory name, and pwd is a command to display it (similar to echo "$PWD" where available). At the library level, pwd can be implemented by a call to getcwd(3).

1
  • 1
    If pwd is read as present working directory then both are quite similar, or almost the same IMO. Commented Jul 15, 2022 at 4:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .