The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
row count of all files with more than 0 byte sri2005 UNIX for Dummies Questions & Answers 6 04-29-2008 06:39 PM
Provide a count of files keymind UNIX for Dummies Questions & Answers 5 12-30-2007 01:57 PM
count of files mahalakshmi Shell Programming and Scripting 13 11-28-2006 09:01 AM
command to count files in dir balireddy_77 Shell Programming and Scripting 4 11-15-2006 01:56 AM
Count number of files in subdirectories cbeverly UNIX for Dummies Questions & Answers 2 06-02-2005 04:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-09-2008
wayne1411 wayne1411 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 9
Display the count of files

I am new to shell programming. Can anyone help me out with anyone of these?

Display a count of the number of regular files, the number of symbolic links, the number of sub-directories, the number of block-special files, and the number of character-special files in the directory.

I don't know how to do any of them. If you can help with one, I'm sure I can figure out the rest. Any help is useful. Thanks.
  #2 (permalink)  
Old 01-09-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,538
to find files of particular type, man find
to count files, man wc
  #3 (permalink)  
Old 01-09-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
to find files

>ls -l | cut -c1 | grep "-" | wc -l

list all files
cut the first character; type of entry
select for a file (not directory, etc)
give a count of number of lines
  #4 (permalink)  
Old 01-09-2008
wayne1411 wayne1411 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 9
Thanks both of you. Both answers proved to be very useful. I now have a much better understanding of find and wc. also, I now feel very confident about the pipe key, whereas before I was somewhat unsure about it. thanks again.

-Kevin
  #5 (permalink)  
Old 01-09-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,538
Quote:
Originally Posted by joeyg View Post
>ls -l | cut -c1 | grep "-" | wc -l

list all files
cut the first character; type of entry
select for a file (not directory, etc)
give a count of number of lines
you can combine cut and grep
Code:
# ls -l | awk '/^-/'|wc -l
184
# ls -l | awk '/^-/{c++}END{print c}'
184
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0