![]() The locate command can be installed by running the following apt command in your terminal: sudo apt install locate In cases like this, the locate command will surely come in handy when you do not know where a file is. Sometimes, when following a tutorial for "Installing and configuring XYZ on CentOS" will show a different location for the config files. The locate command is one of the handiest commands when you do not remember the location of a file. name "*.png"Įasy regex and a quick find! Finding files with locate command I will do so with the following command: $ find. Let us assume I wish to find all the png files. The -name and -iname options accept regular expression strings as inputs. $ du -sh ~/Downloads/mt_file_1ybi ~/Pictures/you_can-t_see_me ~/.config/nvim/mt_file_wun2 ~/Documents/work/learn-ubuntu/mt_file_2qxurĠ /home/pratham/Pictures/you_can-t_see_meĠ /home/pratham/.config/nvim/mt_file_wun2Ġ /home/pratham/Documents/work/learn-ubuntu/mt_file_2qxur Finding files with a particular extension This can be confirmed that they are empty using the du command. home/pratham/Documents/work/learn-ubuntu/mt_file_2qxurĪs you can see, the find command listed all matching results. Note that the -name (or -iname) option is not compulsory. To find those empty files, I will use the -empty flag and specify the type to be a file. I made a mistake in my bash script, and now it has created empty files all over my home directory. ) to search only in the current working directory. ![]() You may also substitute the tilde symbol ( ~) (for home directory) with the period symbol (. Here's the output: $ find ~ -name headshot.pngĪh! It was in the ~/Pictures/self directory. To find the photo, I would modify the find command's parameters as follows: find ~ -name headshot.png Let us assume I have a photo named 'headshot.png' located somewhere in my home directory. But, it does not even cover all the available options for the find command!įor better understanding, let us look at a few common examples of the find command. That is quite a list of available options.
0 Comments
Leave a Reply. |