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!

Scaning a dir for file/directory names

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, im trying to make a small script which will allow someone to scan a directory (from the directory imediently above that one) in order to report back on any files which start with a UPPPER-CASE character, as well as any directorys which start with a lower-case character.

Code:
for var in `ls `
do
if [ -f $var ]
then
echo "file $var"
else
if [ -d $var ]
then
echo "dir $var"
fi
fi
done

Im able to scn for both dirs and files but i still cant get it to report back on what i require.

Hope someone can help.

Thanks :)
 
find /dir -name "[A-Z]*" -type f

Is this what you want?

regards Gregor Gregor.Weertman@mailcity.com
 
Hi,
and the collaray

find /dir -name "[a-z]*" -type d

to find the directories that start with a lowercase letter as

find /dir -name "[A-Z]*" -type f

will only find the FILES that start with an UPPER CASE letter.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top