The UNIX and Linux Forums  


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 -->
  #5 (permalink)  
Old 08-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
That's a script, but it doesn't really conform to your requirements. Specifically, it ignores the case when there is no subdirectory.

The following is a bit contorted but should perhaps work.


Code:
#!/bin/sh
set -o nullglob
pdf=false
for f in /myserver/myfolder/*; do
  test -d "$f" || continue
  for p in "$f"/*.pdf; do
    pdf=true
    X
    break
  done
  $pdf || break
done
$pdf || Z


Last edited by era; 08-28-2008 at 07:10 PM.. Reason: Changed to cope correctly with "any subdirectory without a PDF" requirement