Quantcast
Channel: bash - how to pipe result from the which command to cd - Stack Overflow
Viewing all articles
Browse latest Browse all 8

bash - how to pipe result from the which command to cd

$
0
0

How could I pipe the result from a which command to cd?

This is what I am trying to do:

which oracle | cdcd < which oracle

But none of them works.

Is there a way to achieve this (rather than copy/paste of course)?

Edit : on second thought, this command would fail, because the destination file is NOT a folder/directory.

So I am thinking and working out a better way to get rid of the trailing "/oracle" part now (sed or awk, or even Perl) :)

Edit :Okay that's what I've got in the end:

cd `which oracle | sed 's/\/oracle//g'`

Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>