find command#
Description: Find files using the find command
Syntax: find ~ -iname "filename*"
/**
* For example, if I want to find a .zip file that starts with 'vue-',
* but I forgot its full name and the folder it is in,
* and I want to search within the '~' directory,
* I can use this method for fuzzy searching
*/
find ~ -iname "vue-*.zip"
/**
* It will print all files and paths that match the criteria
*/
find can not only find files, but also find folders
/**
* For example, if I want to find all files or folders that contain 'vue'
*/
find ~ -iname "*vue*"
/**
* It will find all files or folders that contain 'vue'
*/
The find command is simple but requires some expertise. You need to know some basic knowledge of regular expressions, specify the path range, and enclose the search name in quotes, etc.
mdfind command#
Description: Find files using the mdfind command
Syntax: mdfind -name filename
/**
* For example, if I want to find all files or folders that contain 'vue'
*/
mdfind -name vue
/**
* See, I just entered the keyword 'vue' that I want to find
* and it outputs all the files and folders, very convenient
*/
mdfind is straightforward and has no disadvantages, but the prerequisite is that your Mac computer supports Spotlight functionality. However, don't worry, it is generally supported by default on Mac.
Executing Commands in the Shell#
If you have found the file or folder you are looking for, but you want to open it directly, how do you open it? See below
To run a command in the current user's personal folder, prefix it with the folder specifier. For example, to run MyCommandLineProg, use the following command:
% ~/MyCommandLineProg
To open an app, use the open command:
% open -a MyProg.app
Terminating Commands#
-
In the "Terminal" app on Mac, click on the "Terminal" window where the command you want to terminate is running.
-
Press the Control-C key.
-
This sends a signal that causes most commands to terminate.
References#
Executing commands and running tools in Terminal on Mac [1]
Quickly find files or folders with MAC commands, supports fuzzy searching [2]