Simple Listings
We can begin with some simple listing. First we list all PDF files in the current directory and below
find -name '*.pdf'
If we were uncertain on the case of the name that we are search for then we can use iname. This performs a case insensitive search
find -iname '*.pdF'
Now we can do the same but this time for the /usr directory and below. If we do not want to default to the current directory we add the directory path to search.
find /usr -name '*.pdf'
The default search will recurse into all the directories. If we do not want to recurse into directories below we can set the maxdepth attribute. So this is the same but only for the /usr directory .
find /usr -maxdepth 1 -name '*.pdf'
List on Size
There are many attributes of a file we can search upon, not just the name. Here we can also list files greater than a certain size. The dot here is used to represent the current directory,
find . -size +2k -type f
If we want to carry out actions on these files
find . -size +2k -type f -exec ls -lh {} \;
Take a look at my video guiding you through this.
0 comments:
Post a Comment