guys, i did create a script but its too long, though it function the same.
[root@log Sophos]# cat nightlyscan.sh
#!/usr/ksh
deyt=`date +"%Y-%m-%d"`
for i in `ls -lrt|grep $deyt|awk '{print $9}'`
do
cp -f $i /S1/Sophos/logger/
done
[root@log Sophos]#
but i did not paste it all.
this is the desired.
if you have 4 directories
DATA11
DATA22
DATA33
DATA43
And you have files like
DATA11.txt
DATA11.tgz
DATA22.xls
DATA33.as
Output
the directory DATA11 shoud have files of DATA11.txt and DATA11.tgz
DATA22 directory should have file of DATA22.xls and so on.
#!/usr/ksh
deyt=`date +"%Y-%m-%d"`
for i in `ls -lrt /NAS1/Sophos/ |grep $deyt|awk '{print $9}'`
do
cp -f /NAS1/Sophos/$i /NAS1/Sophos/logger/
done
for dir in `ls -d /NAS1/Sophos/logger/*/ | sed 's/.$//'`
do
rm -f $dir/*.tar
mv -f $dir*tgz* $dir/
gunzip $dir/*.tgz
done
I'm still not sure what you request, and I still don't see any difficulties/problems in the snippets provided. If shoving files into aadequate directory is what you want, try e.g.
for FN in DATA* ; do mkdir -p ${FN%.*}; mv $FN ${FN%.*}; done
I'm lost. I don't see any reference to tar xvf in this thread other than you saying you can't use it. If you can't use tar xvf and no one has suggested that you use tar xvf , why is it important for us to know that you can't use tar xvf ?
Usually, when people do not respond to your post is because it is not clear or is missing the necessary information to give you a solution.
I suggest you go back to that thread and add an example of how your file directory tree looks like. Post the output of ls -l from the directory you want to perform the extraction. Also, it might help what kind of errors or warnings you get when command is executed.
Finally, it is most helpful if you explain what do you think or expect to happen and it is not occurring.
Your stated goal was to copy files with filename extensions from one directory into a subdirectory named by the file's name with the filename extension removed. I don't see any connection between that goal and running any of the commands:
rm -f $dir/*.tar
mv -f $dir*tgz* $dir/
gunzip $dir/*.tgz
or
tar xvf /tar/*.tar