The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-29-2009
robert4732 robert4732 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 6
file count with a twist

Hello Everyone,

I am using the korn shell.

I was hoping to find a set of commands to count files in a directory.

I am using:
ls /home/name/abc* | wc -l

This command works fine when a file matches abc* (returns only the file count) , however when no file(s) are found I get something similar to below:

/home/name/abc*: No such file or directory
0

I want only the 0 when a file is not found and not the path or message - 'No such file or directory' .

Can a single unix command accomplish this? Or does a script need to be written?

Thanks in advance.

Robert