×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

simple list with number of files

simple list with number of files

simple list with number of files

(OP)
How do you get the number of files within a directory and it's sub-directories in Unix?  I'm new to this and have no idea.

RE: simple list with number of files

This can be written more concisely, but I left exploded for clarity.


prompt>ls -lR |grep -v ^'./' |grep -v ^total|grep -v ^d|grep -v ^$|wc -l


This recursively lists the contents of directories, then, using 'grep -v', discards lines starting with './' and 'total' and 'd' and empty lines.  The results are piped through 'wc' to get the number of lines remaining.

Oh yeh... this is on Solaris.  Maybe slightly different for Linux or HP-UX or other, but probably not.

'hope this helps.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources