Search for a File

Goal: How to search for a file, by name, across a hierarchy of folders.



Searching for Files:

Let us look at a folder with many subfolders and files.

[]$ cd ~/intro_to_linux [intro_to_linux]$ ls clusters data fruits.txt software.csv vegatables.txt workshop_all.txt workshop_me.txt

The ls by default only lists the first level of folders and files.

What does the -R option do?

[intro_to_linux]$ ls -R .: clusters data fruits.txt software.csv vegatables.txt workshop_all.txt workshop_me.txt ./clusters: beartooth.html loren.html teton.html wildiris.html ./data: 2021 2022 2023 dd.tx ./data/2021: Apr feb Nov README.txt Sep ./data/2021/Apr: 20210403.txt 20210427.txt 20210428.txt ./data/2021/feb: february_01_2021.tx ./data/2021/Nov: 20211114.txt 20211115.txt 20211116.txt hello.txt

Searching for Files: Recursive List Continued

./data/2021/Sep: 20210908.txt 20210921.txt ./data/2022: Dec February Hello.csv Jul Jun readme.txt ./data/2022/Dec: 20221207.txt 20221220.txt 20221230.txt 20221231.txt 2022_dec_01.txt ./data/2022/February: 20220203.txt 20220223.txt ./data/2022/Jul: 20220720.txt 20220722.txt 20220723.TX ./data/2022/Jun: 20220611.txt 20220615.txt 20220624.txt ./data/2023: Feb Jan Mar ReadMe.txt ./data/2023/Feb: 20230204.txt 20230217.txt 20230223.txt 20230224.txt ./data/2023/Jan: 20230102.txt 20230108.txt 20230115.txt 20230121.txt texttx ./data/2023/Mar: 20230305.txt 20230311.txt 20230313.txt 20230326.txt 20230327.txt HELLO.txt ./data/dd.tx:

Check the manual page:


Searching for Files: find

Command

Description

find


Examples


Examples


Exercises: Find Files


Answers (1, 2)

  • That some of the single dash options (-name) are similar to long-names and not single letters.


Answers (3)


Answers (4)


Answers (4)