I can't find a way to pass output of whereis
command to cd
command in same line so I don't have to do cd
in the second step.
I have tried passing like below:
cd $(whereis node_modules)
Or
cd "`dirname $(whereis node_modules)`"
Also
cd "$(whereis node_modules)"
But none of the above method works.
Can somebody find what should be wrong in above codes ?
You can do that with,
cd "`which node_modules`"
With dirname
to get the directory:
cd "$(dirname "$(which node_modules)" )"
as you have mentioned in the comment I am expecting to do this in one step & assuming nod_module
is a directory, so you can do that with the following command:
cd $(whereis node_modules | cut -d ' ' -f2)
(Note that the latter command assumes that the Linux whereis
is being used, not the BSD one, and that the path does not contain any spaces.)
As suggested by @Dani_I, you can have a look at this Why not use "which"? What to use then?, which might be more useful.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加