This simple command will search for a folder named xray* and then switch to it.
┌──[jason@192.168.1.2]─[~/Documents] └──╼ ╼ $ cd $(find . -type d -name "xray*") |
After running this command, it has found a folder that matches the wildcard and then switched to it.
┌──[jason@192.168.1.2]─[~/Documents/xray-16] └──╼ (xd_dev) ╼ $ |
This is how to run a command and have the output be fed into a terminal command as a parameter.
Here is another example, this is a very useful Linux tip.
┌──[jason@192.168.1.2]─[~/Documents] └──╼ ╼ $ cd $(find . -type d -name "op_*") ┌──[jason@192.168.1.2]─[~/Documents/op_2.1_chess_trilogy] └──╼ ╼ $ |
This is another example using the find command, looking for a certain folder that starts with an underscore and then has numbers in the filename.
──[jason@192.168.1.2]─[~/Documents] └──╼ ╼ $ find . -type d -name "_[0-9]*" ./_1600311318239.png.extracted |
Then I can list the contents of this folder easily.
┌──[jason@192.168.1.2]─[~/Documents] └──╼ ╼ $ ls -hula $(find . -type d -name "_[0-9]*") total 1.9M drwxrwxr-x 3 jason jason 4.0K Jan 19 09:48 . drwxr-xr-x 36 jason jason 4.0K Jan 19 09:47 .. -rw-rw-r-- 1 jason jason 0 Sep 21 15:44 5B -rw-rw-r-- 1 jason jason 860K Sep 21 15:36 5B.zlib -rw-rw-r-- 1 jason jason 1.1M Sep 21 15:50 Demiurge.png drwxrwxr-x 2 jason jason 4.0K Jan 19 09:48 _Demiurge.png.extracted |
Because a png image is a compressed file and can be extracted just like a zip file. This is very interesting.