How to Locate Files by Name Ignoring Case in Ubuntu
This guide explains how to search for files within the Ubuntu operating system using the command line. It focuses on the specific command and flags required to perform a case-insensitive search, ensuring you can locate documents regardless of capitalization. You will learn the syntax for the find utility and see practical examples of how to implement this search method effectively.
The Find Command
The primary command used to locate files by name in Ubuntu is
find. To make this search ignore case sensitivity, you must
use the -iname option instead of the standard
-name option. The -name flag distinguishes
between uppercase and lowercase letters, while -iname
treats them as identical.
Basic Syntax
The general structure for this command is as follows:
find [path] -iname [filename]
- [path]: The directory where you want to start the
search. Use
.for the current directory or/for the entire system. - -iname: The flag that enables case-insensitive matching.
- [filename]: The name of the file you are looking
for, often used with wildcards like
*.
Practical Examples
To search for a file named “report.txt” in the current directory and all subdirectories, regardless of whether it is named “Report.TXT” or “report.txt”, run:
find . -iname "report.txt"
If you want to search your entire home directory for any PDF file without worrying about capitalization, use:
find ~ -iname "*.pdf"
Summary
Using find with -iname is the most
efficient way to locate files by name when you are unsure of the exact
capitalization. This method works across all Linux distributions,
including Ubuntu, and requires no additional software installation.