For example I'm in my directory:
/home/myname
and then I want to CD into a different directory.
/home/pulsar/...
Since I need to go pretty deep into the other directory, how can I go about this without having to type the whole line? I tried
cd */thedirectoryiwanttogointo
but that doesn't work. I have to type the whole line.
Best Answer
Probably your wildcard does not work because:
The usual approach (in a shell) to moving frequently among subdirectories is to use the
CDPATH
feature, as well aspushd
andpopd
.The
CDPATH
feature (perhaps first seen in tcsh) is a colon-separated list of directories. If the parent of yourthedirectoryiwanttogointo
name is reasonably unique, then you could add the parent to the list.For further reading (your shell's manual page should be first):
cd
(Red Hat Enterprise Linux Step By Step Guide)pushd
andpopd
are newer thanCDPATH
, but still dating from the mid-1990s. They allow you to save your current directory ("pushing" onto a stack) and restore it ("popping" from a stack) during their respectivecd
commands. For further reading:Other people use shell aliases or symbolic links. Those are most useful when going to well-known locations.