Skip to content
Advertisement

which is better? using cd and execute or using absolute path?

Suppose I would like to do some operation like touch/rmetc on a specific directory in shell script. Firstly, I can do cd to that directory and do it. Secondly, I can use absolute path to do that.

My question is which one will be better in performance perspective? Which one is faster?

Advertisement

Answer

You can time it yourself:

JavaScript

with this I get:

JavaScript

so it is almost the same for this many iterations on the path I tried

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement