The UNIX and Linux Forums  


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




Thread: ls command help
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 10-24-2006
BOFH BOFH is offline Forum Advisor  
Registered User
  
 

Join Date: Feb 2005
Location: Broomfield, CO
Posts: 406

Code:
#!/bin/ksh

if [ -f existentFiles ]
then
  rm existentFiles
fi

for a in /etc/magic /sbin/fsck /boot/grub/menu.lst /usr/share/games/wombat /var/cache/man/index.db /usr/bin/defcon

do
  if ( ls $a > /dev/null 2>&1 )
  then
    echo $a >> existentFiles
  fi
done

On my Mandrake box (using /bin/bash as the first line) I get:


Code:
$ cat existentFiles
/sbin/fsck

On my OpenBSD box (using /bin/ksh as the first line) I get:


Code:
$ cat existentFiles
/etc/magic
/sbin/fsck

Carl