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 -->
  #2 (permalink)  
Old 01-25-2008
V3l0 V3l0 is offline
Registered User
  
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
Hello,

First, when you select "*log*", you don't have to select "*.log*" beacause they are already in the first selection !

Second, why "touching" the file before deleting it ?

Third, your script will be runnig with "unable to remove file xxx" beacause of the command "rm -f $filestodelete" that will delete all the files selected by "for files in (*log*|*.log*)"

So, I propose you the script :

Code:
list=$(ls *log*)

for file in $list
do
    cp $file $file.$(date +%a)
    rm -f $file
done