Thursday, March 11, 2010

Does a File Exist?

for EXTENSION in txt TXT csv CSV xls XLS            # For each one in this list,
do                                                  # do the following:
  echo $EXTENSION                                   # Display the extension.
  if [ -e *.$EXTENSION ];                           # if a file exists like that...
     then ls *.$EXTENSION |wc -l                    # then display the count
          mv *.$EXTENSION /dfact/fchecks/out_backup # move file to the backup dir
     else echo '    -- not found'                   # otherwise, display 'not found'   
  fi
done

No comments:

Post a Comment