• 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 👈

Find files and directories on Linux with the find . command

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

Guide to self -creation socket5 on Ubuntu
Network

Guide to self -creation socket5 on Ubuntu

May 28, 2025
How to create a separate mtproto proxy to use Telegram when blocked
Network

How to create a separate mtproto proxy to use Telegram when blocked

May 25, 2025
Script backup database and website on telegram
Network

Script backup database and website on telegram

May 2, 2025
Create 64GB RAM 16 core for free on Google IDX
Network

Create 64GB RAM 16 core for free on Google IDX

April 13, 2025
What is VPS running Vietnamese software? What is the reason for installing Vietnamese software on VPS?
Network

What is VPS running Vietnamese software? What is the reason for installing Vietnamese software on VPS?

February 17, 2025
Create Ronin wallet to play pixels on VPS Windows
Network

Create Ronin wallet to play pixels on VPS Windows

February 17, 2025
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

How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions on how to fix Screen Time Limited Reached on RoBlox

Instructions on how to fix Screen Time Limited Reached on RoBlox

August 13, 2025
How to install GPT-suns on who do not need the Internet

How to install GPT-suns on who do not need the Internet

August 12, 2025
How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions on how to fix Screen Time Limited Reached on RoBlox

Instructions on how to fix Screen Time Limited Reached on RoBlox

August 13, 2025
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

How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

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