I'm searching for a config folder, and trying to change to that directory:
find . -name "config" -exec cd {} \;
There is one match, ./my-applications/config
, but after I try this it says:
find: `cd': No such file or directory
What am I doing wrong?
Open System Information. In the System Information window, click the + symbol next to Components. If you see "CD-ROM," click it once to display the CD-ROM in the left window. Otherwise, click "+" next to "Multimedia" and then click "CD-ROM" to see the CD-ROM information in the left window.
Usually on Linux, when an optical disc is mounted, the eject button is disabled. To determine whether anything is mounted in the optical drive, you can check the contents of /etc/mtab and look for either the mount point (e. g. /mnt/cdrom ) or the device for the optical drive (e. g. /dev/cdrom ).
The command cd
is a shell built-in, not found in /bin
or /usr/bin
.
Of course, you can't change directory to a file and your search doesn't limit itself to directories. And the cd
command would only affect the executed command, not the parent shell that executes the find
command.
Use:
cd $(find . -name config -type d | sed 1q)
Note that if your directory is not found, you'll be back in your home directory when the command completes. (The sed 1q
ensures you only pass one directory name to cd
; the Korn shell cd
takes two values on the command and does something fairly sensible, but Bash ignores the extras.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With