• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

How to use the Find command Find files and folders on Linux

AnonyViet by AnonyViet
January 25, 2023
in Network
0

No matter how determined I was to organize the data, every time I looked for the file, I couldn’t find it anywhere. Sometimes it’s because I can’t remember the file name. But remember the file name but don’t remember where to save it, it’s the same. However, in this article, I will guide you to find files or folders on Linux with the find command.

Join the channel Telegram of the AnonyViet 👉 Link 👈

How to use the Find command Find files and folders on Linux

Install find . command

The find command is defined by POSIX, which creates the open standard by which POSIX systems (including Linux, BSD, and macOS) will be compatible. Simply put, you should be able to install this command as long as you’re running Linux, BSD, or macOS.

However, not all find commands are exactly the same. For example, the GNU find command has features that the BSD or Busybox or Solaris find commands may not have, or have, but work differently. This article uses GNU find from the package findutils because it is available and quite popular. Most of the commands presented in this article work with other implementations of find, but if you try the find command on a non-Linux platform and get unexpected results, try downloading and installing it. set GNU version.

Find files by name

You can find files by name by providing the full filename or parts of the filename using regular expressions. The find command asks for the path to the directory you want to search, there are also other options like -name for the case-sensitive filename and then the search string. By default, the find command searches for the exact filename of the string you enter between double quotes unless you use the egular expression syntax.

Let’s say your Documents folder contains four files: Foo, foo, foobar.txt, and foo.xml. Here’s how to find the file named “foo”:

$ find ~ -name "foo"
/home/tux/Documents/examples/foo

You can expand your search by being case sensitive with the -iname option:

$ find ~ -iname "foo"
/home/tux/Documents/examples/foo
/home/tux/Documents/examples/Foo

Find files by wildcard

You can use basic shell wildcards to expand your search. Example: asterisk

$ find ~ -iname "foo*"
/home/tux/Documents/examples/foo
/home/tux/Documents/examples/Foo
/home/tux/Documents/examples/foo.xml
/home/tux/Documents/examples/foobar.txt

represent any number or character:

$ find ~ -iname "foo*.???"
/home/tux/Documents/examples/foo.xml
/home/tux/Documents/examples/foobar.txt

The question mark (?) represents a character:

This is not a regular expression syntax, so the dot (.) represents a literal dot.

Find files with Regular expressions

$ find ~ -iregex ".*foo"
/home/tux/Documents/examples/foo
/home/tux/Documents/examples/Foo

You can also use regular expressions. As with -iname and -name, are case-sensitive and case-insensitive options. However, unlike the -name and -iname options, the -regex and -iregex options are applied to the entire path, not just the filename. That means if you search for foo you will get no results because foo doesn’t match /home/tux/Documents/foo. You have to search the entire path instead, or use wildcards:

Find files modified in the last week

$ find ~ -mtime -7
/home/tux/Documents/examples/foo
/home/tux/Documents/examples/Foo
/home/tux/Documents/examples/foo.xml
/home/tux/Documents/examples/foobar.txt

To find the file you last modified last week, use the -mtime option along with the number of (negative) days in the past:

Find files that have been modified within a few days

$ find ~ -mtime +1 -mtime -7

You can combine the -mtime options to find files in a date range. For the first -mtime option, provide the most recent number of days on which you may have modified the file, and for the second option, provide the largest number of days. For example, the command below searches for files that have been modified more than one day in the past, but not more than seven:

Limit search by file type

  • d You can optimize search results by specifying the file type you are looking for. You shouldn’t use this option if you’re not sure what you’re looking for, but if you know you’re looking for a file and not a folder, or a folder but not a file, it can be an option. great choice. The option is -type and its arguments are wildcards for several different data types. The most popular are:
  • f – folder
  • l – file
  • s – symbolic link
  • p – sockets
  • b – named pipe (used for FIFO)

– special block (usually hard drive symbol)

$ find ~ -type d -name "Doc*"
/home/tux/Documents
$ find ~ -type f -name "Doc*"
/home/tux/Downloads/10th-Doctor.gif
$ find /dev -type b -name "sda*"
/dev/sda
/dev/sda1

Here are some examples:

Adjust range

$ find /usr -iname "*xml" | wc -l
15588
$ find /usr -maxdepth 2 -iname "*xml" | wc -l
15

The find command is recursive by default, which means it searches for results in subdirectories. This can take time for a large filesystem, but you can use the -maxdepth option to control how deep the recursion is.

$ find /usr -mindepth 8 -iname "*xml" | wc -l
9255

You can alternately set the minimum recursion depth with -mindepth: In addition, you can also see 10 more dangerous Linux commands that absolutely should not be tried

here.

The article achieved: 5/5 – (100 votes)

Tags: CommandfilesFindfoldersLinux
Previous Post

Lesson 161: Find the cell address with the largest value in Excel

Next Post

Get Seed4Me’s 6-month VPN License License

AnonyViet

AnonyViet

Related Posts

Save image as Type contains malicious code: Remove immediately before losing money unfairly!
Network

Save image as Type contains malicious code: Remove immediately before losing money unfairly!

March 19, 2026
Instructions on how to register a .co.uk domain name for free for 1 year
Network

Instructions on how to register a .co.uk domain name for free for 1 year

March 12, 2026
How to Setup Paperclip AI: Create a Company for AI Agent
Network

How to Setup Paperclip AI: Create a Company for AI Agent

March 12, 2026
Compilation of free and cheap APIs to run OpenClaw stably
Network

Compilation of free and cheap APIs to run OpenClaw stably

March 10, 2026
3 Services to Determine IP Location for Website (IP Geolocation API)
Network

3 Services to Determine IP Location for Website (IP Geolocation API)

March 10, 2026
How to buy a .STORE domain name for 1 USD (2026): Detailed instructions from A–Z
Network

How to buy a .STORE domain name for 1 USD (2026): Detailed instructions from A–Z

March 3, 2026
Next Post
Get Seed4Me’s 6-month VPN License License

Get Seed4Me's 6-month VPN License License

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Instructions for looking up prescriptions on VNeID instead of paper medical books

Instructions for looking up prescriptions on VNeID instead of paper medical books

April 26, 2026
Tips to completely turn off CAPTCHA codes on iPhone and Mac are super simple

Tips to completely turn off CAPTCHA codes on iPhone and Mac are super simple

April 25, 2026
Compare Poco X8 Pro and Poco X7 Pro: A new step for the “king” of mid-range performance

Compare Poco X8 Pro and Poco X7 Pro: A new step for the “king” of mid-range performance

April 24, 2026
How to compress online videos for free without losing quality

How to compress online videos for free without losing quality

April 24, 2026
Instructions for looking up prescriptions on VNeID instead of paper medical books

Instructions for looking up prescriptions on VNeID instead of paper medical books

April 26, 2026
Tips to completely turn off CAPTCHA codes on iPhone and Mac are super simple

Tips to completely turn off CAPTCHA codes on iPhone and Mac are super simple

April 25, 2026
Compare Poco X8 Pro and Poco X7 Pro: A new step for the “king” of mid-range performance

Compare Poco X8 Pro and Poco X7 Pro: A new step for the “king” of mid-range performance

April 24, 2026
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

Instructions for looking up prescriptions on VNeID instead of paper medical books

Instructions for looking up prescriptions on VNeID instead of paper medical books

April 26, 2026
Tips to completely turn off CAPTCHA codes on iPhone and Mac are super simple

Tips to completely turn off CAPTCHA codes on iPhone and Mac are super simple

April 25, 2026
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply