Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]

Search This Blog

Thursday, May 10, 2012

Copy file from source to destination when size > 0 bytes

#!/bin/ksh
wdate=`date '+%Y-%m-%d'`
wdate1=`date '+%m%d%y'`
logdate=`date '+%m%d%y%H%M%S'`
source=/your source/$wdate
destination=/yourdestination
log_dir=/loglocations/log
log=$log_dir/logfilename_$wdate1.log
while true
do
  if [ -d "$source" ]
  then
echo $source
echo $source/*.csv
      if [ ! -s "$source/*.csv"  ]
      then
         echo " File exists- copying the File to destination @$logdate" >> $log
         cp  $source/*.csv $destination/logfilename_$wdate1.csv
         echo " copied the file..exiting now  $logdate" >>$log
         exit 0
      else
   echo "sleepping ..."
          sleep 10
      fi
  fi
echo $wdate
done

Tuesday, May 1, 2012

find files within directories



find . -type f -exec grep -il "hello" {} \;

or if you know the file type

find . -type f -name "*.ext" -exec grep -il "hello" {} \