The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-09-2008
aishu aishu is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 2
Thumbs up script for deletion using wildcards

find ./ -name t\* | sed "s@^./@@" > .filestobedeleted

j=$(wc -l < .filestobedeleted)

typeset -i cnt=0

typeset -i i=0

while read line

do

myarray[$cnt]=$line

((cnt = cnt + 1))

done < .filestobedeleted

while [ ${i} -le ${j} ]

do

file=${myarray[$i]}

destfile=$(basename ${file})

ABS_PATH=$(cd $(dirname ${file});pwd)

suffix=$ABS_PATH/${destfile}_$(date +%d%m%y%H%M%S)

timestamp=${suffix##*_}

echo $suffix >> $HOME/.trashinfo

mv -vi "$file" "$HOME/.trash/${destfile}_${timestamp}"

((i = i + 1))

done



in the first line , I have specified the input directly



instead we should receive the input which is generally using $1 as below but if I give the input as $1 it does not recognize t\*



there is something that needs to be done , kindly check



find ./ -name $1 | sed "s@^./@@" > .filestobedeleted