Why does the wildcard * not work when changing directories?

JobHunter69

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.

Thomas Dickey

Probably your wildcard does not work because:

  • there were no matches for the wildcard from the location you gave, or
  • there was more than one match.

The usual approach (in a shell) to moving frequently among subdirectories is to use the CDPATH feature, as well as pushd and popd.

The CDPATH feature (perhaps first seen in tcsh) is a colon-separated list of directories. If the parent of your thedirectoryiwanttogointo name is reasonably unique, then you could add the parent to the list.

For further reading (your shell's manual page should be first):

pushd and popd are newer than CDPATH, 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 respective cd commands. For further reading:

Other people use shell aliases or symbolic links. Those are most useful when going to well-known locations.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Why does this "find" command scan all directories?

분류에서Dev

Why does "and" work when specifying specific file extensions and not "or"

분류에서Dev

Why and how does this work?

분류에서Dev

Why does all Word.Range object change when changing one of them?

분류에서Dev

Changing directories with Bash

분류에서Dev

Why does changing $PATH affect child shells, but changing $foo not?

분류에서Dev

Why does grep ignore the shell variable containing directories to be ignored?

분류에서Dev

Why does pkill not work with rofi?

분류에서Dev

Why does sudo not work with curl?

분류에서Dev

Why does remove(x) not work?

분류에서Dev

Why does this angularjs directive not work?

분류에서Dev

Why does this rename operation not work?

분류에서Dev

Why does this type of inheritance work?

분류에서Dev

Why does my C++ function, only when it's placed after main(), not work?

분류에서Dev

Why does this C code not work in JavaScript?

분류에서Dev

Why does this command work for logging script output?

분류에서Dev

Why NodeJS KeepAlive does not seem to work as expected?

분류에서Dev

Why does this C code not work in JavaScript?

분류에서Dev

Why does `kill %jobnumber` not work on stopped jobs?

분류에서Dev

Why does the first assert work, but not the second?

분류에서Dev

Why does this CURL work in PHP but not in the shell

분류에서Dev

Why does strcat not work with empty string in C?

분류에서Dev

Why does the following code only work with GridLayout?

분류에서Dev

Why does setTo not work (assertion failed)?

분류에서Dev

Why does Docker "ancestry" API command not work?

분류에서Dev

Why does my bubble sort method not work?

분류에서Dev

Why my cron Job does not work?

분류에서Dev

Why does my xdotool key command not work?

분류에서Dev

Why does command injection not work in this example?

Related 관련 기사

뜨겁다태그

보관