July 12, 2023

Find files or directories from the command-line with find

find is a programme to search for files and directories (commonly called folders).

Find a file you know the name of

For example, if you are looking for a file named report.txt in your home directory run:

$ find /home/user/ -name report.txt 

where:

$ is the prompt of your terminal.

/home/user/ the starting-point in the directory hierarchy.

-name an option that tells find the name of the file.

If the files report.txt exists, the path of the file will be printed in the terminal, for example:

/home/user/Document/report.txt

Still in the terminal, you can preview report.txt by running $ less report.txt.

If many directories including the word report exist, you can tell find to exclude directories from the search results by adding the option -type f such as:

$ find /home/user/ -name report.txt -type f

Find a directory

Conversely, -type d will only list directories.

Find a file or directory you don’t know the exact name of

What if you don’t know the exact name of the file?

Use regular expressions.

For example if you know that the word report is in the name of the file you are looking for, run:

$ find /home/user/ -name *report*

If you don’t know whether report is written small cap or large cap, run:

$ find /home/user/ -iname *report*

The option -iname is like -name, but the match is case insensitive.

For more information about find run $ man find.

find is copyleft-licensed and was published in 1971.

✍✍✍✍✍✍✍✍✍✍✍✍✍✍

I do self-funded research and I'm writing a book.

> What's the book about?

About technologies and agency.

Meaning, technologies can foster agency. No doubt. But I am also asking:

Can usage of technologies give us a sense of empowerment while in fact undermining our abilities?

I posted a summary of the prologue on the homepage: https://yctct.com/

✍✍✍✍✍✍✍✍✍✍✍✍✍✍


personal computing command-line interface (cli) gnu linux trisquel office applications text processing find wiki shell literacy

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct.com is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88