Jaur
Jaur

Reputation: 85

Find/list files ignoring uppercase/lowercase

How to list/find files that may or may not have uppercase letters. Lets say i have files in a folder: README.txt, Readme.txt, readme.txt, Readme.TXT, LICENCE.txt, licence.txt etc How do i list only files that have "readme" in file name and ignore all others. I can't use [A-Z] or [a-z]. Is there a better way to list all those readme.txt files? I know that [:alpha:] will ignore upper/lowercase - how to use it with ls of find?

Upvotes: 1

Views: 2173

Answers (1)

SMA
SMA

Reputation: 37063

You could do the following:

ls | grep -i '^readme.txt$'
find . -maxdepth 1 -iname "readme.txt"

First ls command would search for readme.txt ignoring the case using -i option in grep.

Find command would find readme.txt by ignoring case in your current directory.

Upvotes: 3

Related Questions