![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| unix command/s to find files older than 2 hours in a directory | Presanna | Shell Programming and Scripting | 6 | 11-20-2007 09:22 AM |
| How to delete Directory and inside files using Find command | bmkreddy | SUN Solaris | 3 | 07-10-2007 02:35 PM |
| How to find the count of files in a directory | sish78 | UNIX for Dummies Questions & Answers | 5 | 02-01-2007 03:58 PM |
| Help Using Grep command to Find the string in the files in the root directory | Subbu_Angeline | AIX | 3 | 01-17-2007 01:45 PM |
| Find occurances of a directory and count | stringman | Shell Programming and Scripting | 2 | 08-18-2005 03:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
This works but only if there actually are files in the directory... if there are only directories, or no files at all, it responds with an error and a '-1', because the 'ls -l' fails
Code:
ls -l *.* | wc | awk -F ' ' '{print $1-1}'
|
|
||||
|
Quote:
Code:
awk 'BEGIN {
while ( ( "ls -l /yourdir" | getline line ) >0 ) {
if ( line ~ /^-/ ){
c++
}
}
print "Total files: ", c
}
'
Code:
ls -ltr | awk '/^-/{ c++;}END{print c}'
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|