Computing.Net > Forums > Unix > File names

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

File names

Reply to Message Icon

Name: ohuang
Date: October 5, 2009 at 11:33:15 Pacific
OS: AIX
Subcategory: General
Comment:

Hello,
I'd like to find all file names that are larger than 6 digits long in a directory. What unix command I should use? awk?

thanks for any help.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: October 5, 2009 at 12:50:02 Pacific
Reply:

I prefer using the shell. This works even if your filename contains spaces:

#!/bin/ksh

ls -l |while read f1 f2 f3 f4 f5 f6 f7 f8 filename
do
  # only use files
  if [[ $(echo $f1|cut -c1) == "-" ]]
  then
     if [[ ${#filename} -gt 6 ]]
     then
        echo $filename
     fi
  fi
done


1

Response Number 2
Name: ohuang
Date: October 6, 2009 at 08:43:01 Pacific
Reply:

Works like a charm. Thank you very much for your help!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: File names

Extracting File names www.computing.net/answers/unix/extracting-file-names/4597.html

How to delete a file named -x www.computing.net/answers/unix/how-to-delete-a-file-named-x/3350.html

flexibility in file naming schemes?? www.computing.net/answers/unix/flexibility-in-file-naming-schemes/570.html