Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check for existance of file case insensitively 1

Status
Not open for further replies.

philipose

Programmer
Dec 24, 2003
137
US
Hi,
Is there an elegant way to verify if a bunch of files (names case insensitive) exist in a directory ?

ie I can get files named google*.csv (case insensitive, * stands for wild character). ie I can get Google123.csv, GOOGLE.csv, google343.csv, etc

rather than saying
if [-f google*.csv] || [-f Google*.csv] || ...
I was searching for a better way to deal with this situation.

Thanks in advance
philipose
 
something along the lines of
Code:
if ls *.csv | egrep -iq ^google
then
  echo file found
fi

Of course, if you actually want to kneo what's been found then
Code:
for i in $(ls *.csv | egrep -i ^google)
do
  echo found $i
done

Ceci n'est pas une signature
Columb Healy
 
Columb,
This is cool. Thanks a lot. I did not think along the same lines.
Philipose
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top