...
Command | Description | ||
find |
|
...
Examples
Info |
---|
Find the file named: |
Code Block |
---|
[]$ cd ~/intro_to_linux/
[intro_to_linux]$ find . -name 20230121.txt
./data/2023/Jan/20230121.txt
# Check that this file is within the returned location.
[intro_to_linux]$ ls data/2023/Jan/
20230102.txt 20230108.txt 20230115.txt 20230121.txt
# Nothing returned – no file exists called “20230120.txt”
|
Info |
---|
Find the file named: |
Code Block |
---|
[intro_to_linux]$ find . -name 20230120.txt
[arcc-t05@blog1 intro_to_linux]$
|
Info |
---|
The command completed since we got back to the prompt and no errors were displayed. No output means that this file could not be found. |
Info |
---|
Find is case-sensitive. Find the file with the exact filename |
Code Block |
---|
[intro_to_linux]$ find . -name README.txt
./data/2021/README.txt
# find is case–sensitive: use –iname option
|
Info |
---|
Use the alternative |
Code Block |
---|
[intro_to_linux]$ find . -iname README.txt ./data/2021/README.txt ./data/2022/readme.txt ./data/2023/ReadMe.txt |
...
Examples
Code Blockinfo |
---|
# Use wildcards to find all files with the postfix |
Code Block |
---|
[intro_to_linux]$ find . -name "*.csv"
./software.csv
./data/2022/Hello.csv
# Find any |
Info |
---|
Find any files/folders that contain the string “dec”string |
Code Block |
---|
[arcc-t05@blog1 intro_to_linux]$ find . -name "*dec*" ./data/2022/Dec/2022_dec_01.txt [arcc-t05@blog1 intro_to_linux]$ find . -iname "*dec*" ./data/2022/Dec ./data/2022/Dec/2022_dec_01.txt # Find only folders. |
Info |
---|
Find only folders using the Question: Are we searching with respect to case-sensitive or insensitive? |
Code Block |
---|
[arcc-t05@blog1 intro_to_linux]$ find . -type d -iname "*dec*"
./data/2022/Dec
# Find only files
|
Info |
---|
Find only files using the |
Code Block |
---|
[arcc-t05@blog1 intro_to_linux]$ find . -type f -iname "*dec*" ./data/2022/Dec/2022_dec_01.txt |
...