![]() |
|
|
google unix.com
|
|||||||
| Forums | Casino | Register | Forum Rules | Links | Albums | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Cp files (>5 Mb size) from one directory to another | skcontact | UNIX for Dummies Questions & Answers | 6 | 06-12-2008 07:39 AM |
| searching files inside directory | kylethesir | UNIX for Dummies Questions & Answers | 4 | 06-06-2008 01:44 AM |
| How to see directory and the files inside it. | shaan_dmp | UNIX for Advanced & Expert Users | 4 | 12-17-2007 04:48 AM |
| How to delete Directory and inside files using Find command | bmkreddy | SUN Solaris | 3 | 07-10-2007 02:35 PM |
| How to check if 3 files have same size in directory | oggle | Shell Programming and Scripting | 5 | 02-16-2005 11:51 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
files of size 0 need to be deleted inside a directory
Hiiii,
I have written a script which takes backup of some log files. let say the backuplocation is --- /abc/backuplocation -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt23994.log -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt3601.log -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt3619.log -rw-r----- 1 webmut2 spgroup 1551 Jan 25 07:13 ansrpt3619.log after taking the backup i have to delete the files and then touch the files so that it create the file but with size 0 this is required in the script. suppose the location of the files that need to backed up is--- /namish/logs -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt23994.log -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt3601.log -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt3619.log My script is working fine for all these but a problem is coming ie when i am touchng the files they are still under the directory /namish/logs,when again i ran the script,my script is picking these files(files with size 0) also and taking the backup.I do not want this because this time the size of the file will be 0. My script should delete the files from the backuplocation whose size is 0. The script is ----- Code:
l) BackupLocation="$OPTARG"
if [[ $BackupLocation != *backup ]]; then
echo "Appending backup subdirectories"
BackupLocation=$BackupLocation/backup
mkdir -p $BackupLocation >/dev/null 2>&1
if [[ $? != 0 ]];then
echo "First Create The Directory And Then Take backup"
fi
cd $FileLocation
pwd
cp -R $FilesToDelete $BackupLocation
list=$(ls *log*)
for files in $list
do
echo $files >namish1
rm -f $files
touch $files
done
else
mkdir -p $BackupLocation >/dev/null 2>&1
cp -R $FilesToDelete $BackupLocation
for files in $list
do
rm -$files
touch $files
done
if [[ ! -d $BackupLocation ]]; then
echo "Unable to make backup directory: $BackupLocation"
if [[ $IsCronJob -eq 1 ]]; then
SendMiddleTierCleanMail "Middletierclean error message" $mt_clean_errfile
fi
return $E_INT_MISSING_DIR
fi
fi
l_flag=Y
Llcron=l
;;
|
| Sponsored Links |
![]() |
| Bookmarks |
| Tags |
| None |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|