5

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)?

roaima
  • 107,089
  • 14
  • 139
  • 261
account
  • 53
  • 1
  • 4

1 Answers1

9
  • 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).

roaima
  • 107,089
  • 14
  • 139
  • 261