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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 06-28-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
You can avoid using the ls command here. Also, mbketan, using '-f' is perhaps better that using '-s' in this case, as the OP may also want to test for empty (zero byte) files.
Code:
#!/usr/bin/ksh
for file in *; do
[[ -f $file ]] && echo $file is a regular file
done
Wait a minute, it seems that the OP wants to test for a list of filenames that (s)he already has. In that case, do this:
Code:
#!/usr/bin/ksh
for file in $@; do
[[ -f $file ]] && echo $file exists
done

Last edited by blowtorch; 06-28-2006 at 12:28 AM..