Find files using a wildcard in UNIX
When you want to find all of the files matching a certain filename pattern, a wildcard can be used with the find command
To find all files ending with .html:
find / -name \*.html -print
The character causes the shell to ignore the following character , in this case an asterisk. To find a file that starts with project:
find / -name project\* -print
Multiple wildcards can be used in the same find command. The following command finds all files with the word maybe in it:
find / -name \*maybe\* -print
The backslash \ character is important. It tells the shell not to treat the wildcard character as a wildcard when interpreting the command line arguments.
Also see ...
Search for text in vi or vim
H3vi and vim have powerful searching capabilities because they bring to bear the richness of regular expressions. /H3PTo search for the next occurence of the text 'maybe' from the current cursor position, type: br / br /div class="code"/maybe<ENTER> br /P br /Search ba
H3vi and vim have powerful searching capabilities because they bring to bear the richness of regular expressions. /H3PTo search for the next occurence of the text 'maybe' from the current cursor position, type: br / br /div class="code"/maybe<ENTER> br /P br /Search ba
Find out which process is holding which socket open
H3You've run netstat an. You see that port TCP/65237 is listening. What program is actually running and holding that port open? Here's how to find out./H3PSometimes you notice odd ports open and listening on your machine. In this day and age, that's often a bad thing. But what do you kil
H3You've run netstat an. You see that port TCP/65237 is listening. What program is actually running and holding that port open? Here's how to find out./H3PSometimes you notice odd ports open and listening on your machine. In this day and age, that's often a bad thing. But what do you kil
Find and delete all core files
H3Locate and remove all core files in system using the find command/H3Pdiv class="code"find / name core exec rm &123;&125; \;P br /The find command replaces the {} characters in the command above with the filenames that it finds. You must include the \ immediately before the ;
H3Locate and remove all core files in system using the find command/H3Pdiv class="code"find / name core exec rm &123;&125; \;P br /The find command replaces the {} characters in the command above with the filenames that it finds. You must include the \ immediately before the ;
Find all empty files in a UNIX filesystem
H3Using the find command, locate all files with zero length/H3PTo find all empty files on the entire system, br / br /div class="code"find / size 0 printP br /To find all empty files from the current directory down, br / br /div class="code"find . size 0 printP
H3Using the find command, locate all files with zero length/H3PTo find all empty files on the entire system, br / br /div class="code"find / size 0 printP br /To find all empty files from the current directory down, br / br /div class="code"find . size 0 printP
Limit the depth of search using find
H3The find command searches all subdirectories under the specified path by default. Using the maxdepth option, the search depth can be limited./H3PTo run a find command limited to only the current directory and not search through any subdirectories, use the maxdepth 0 option: br / br /d
H3The find command searches all subdirectories under the specified path by default. Using the maxdepth option, the search depth can be limited./H3PTo run a find command limited to only the current directory and not search through any subdirectories, use the maxdepth 0 option: br / br /d
