ls -c /dir1/dir2/test* | while read fileName
do
mv $fileName ${TargetDir}
echo "Moving file: ${fileName} to ${TargetDir}" >> $LOGFILE
done
In the above scenarion it will move all the files which is having pattern test* from the current directory to TargetDir directory.
What I need is after moving those files I want to zip all the files to one file
For example.I have files like below(the number of files can vary.It can be either 3 0r 10 etc)
test12
test23
test25
So it will move all the three files.Now I need a zip file like below.
When I do a gzip -c /dir1/dir2/test* > ${TargetDir}/test_Date.gz.All the files will be zipped into test_Date.gz file,But still all files will be there in that path itself.I dont want that files there in that path.I need to remove that file while I do zip