Linux - how to search for find and locate files and directories?

Linux - how to search for find and locate files and directories?

Hi, I need to learn how to search by file name and directory name in a Linux terminal. What I was looking at is using the find a locate command, but I don't understand how to use it. How could I search for this:

Any file named *FILE3*. *
Exactly a file named FILE3.mkv

Any directory named *DIR2*
Exactly a directory named DIR2

REPLY


Hi,

here are a few examples of how to use find and locate to search through terminal linux:

Find


# Any file named * FILE3 *. *
find /home -name "FILE3. *"

# Exactly the file named FILE3.mkv
find /home -name "FILE2.mkv"

# Any directory named * DIR2 *
find /home -type d -name "* DIR2 *"

# Exactly a directory named DIR2 (-name)
find /home - type d - name "DIR2"

# Ignore uppercase and lowercase letters (-iname)
find /home -type d-in "DIR2"

# Find files do not contain string
find /home \! -name "string"

# Files smaller than 500MB
find /home -size -500M

# Files larger than 7GB
find /home -size + 7G

# Find by file type (f - file, d - dir, b - block dev)
find /home - type l

# Find and delete * .tmp files
find /tmp -name "* .tmp" -delete

# Find by time
- modified 3 days ago = find /home + mtime 3
- accessed less than 2 days ago = find /home -atime -2
- changed metadata more than 7 days ago = find /home -ctime +7

# Find - more options are found by:
- -user
- -group
- -perm permissions

# Find - additional parameters
- search depth -maxdepth 4
- Follow the -L symbols
- Optimalization (1, 2, 3) of -O3



Locate


The locate command uses db, so searching should be faster than find, but it can't do that much like find
#Installation locate
apt install mlocate
#update db for locate
updatedb
# status db
locate -S
locate FILE3
locate -b FILE3
# Existing files only
locate -e FILE3

Související obsah

linux

terminal

bash

find

locate

Komentáře

Vaše reakce na Linux - jak vyhledávat příkazem find a locate soubory a adresáře?

Reference

Podívejte se na naše reference

Prohlédnout

Aplikace

Podívejte se na naše aplikace

Prohlédnout

Co umíme?

Podívejte se co umíme

Prohlédnout

Co umíme?

Vytváříme sofistikované aplikace pro náročné

Od webových aplikací přes android až po převodové můstky či složité informační systémy.

Podívejte se k nám

Máte ještě čas? Podívejte se na další rubriky

Tento web používá soubory cookie. Dalším procházením tohoto webu vyjadřujete souhlas s jejich používáním.. Více informací zde.