Requirement: i need to delete the files and to know how many files are deleted i.e the count of files and even i need to display when the started time of deletion and the ending time of deletion. I need to display these two times.
script:
error:
test1:integ>./Purging.sh
/opt/CGEYScripts/coredumps.ctl
/opt/CGEYScripts/cored
./Purging.sh[8]: j: not found
Can anyone modify the script that meets my requirement, please?
Last edited by bakunin; 12-18-2008 at 07:05 AM..
Reason: added code-tags. Please use them yourself from now on
First, you have used a backquote instead of a dollar sign in the last line where you display the variable j, which is causing the last error.
Second, you should not use backquotes any more, they are outdated. Use "$(...)" instead.
Third, - only if you use ksh - use "print" instead of "echo", because "print" is a built-in while "echo" is an external command.
Fourth, you should not use "for"-loops to cycle through arbitrary lists, because they could become longer than what your shell could fathom. Use a pipeline instead:
For a fitting format string for "date" consult the manpage of "date".
#!/bin/bash
#
name=$1
type=$2
number=1
for file in ./**
do
if
then
filenumber=00$number
elif
then
filenumber=0$number
fi
tempname="$name""$filenumber"."$type"
if (4 Replies)
I have 4 files in a directory and want to delete only first 2 files only..
$ ls -ltr
total 640
-rw-r--r-- 1 user other 148779 Oct 12 10:50 file1.xls
-rw-r--r-- 1 user other 148779 Oct 12 10:50 file2.xls
-rw-r--r-- 1 user other 148779 Oct 12 10:50 file3.xls... (4 Replies)
Hi guys,
I am new to shell scripting and I need urgent assistance.
I have an xml like :
<AgreementNumberFull>13-WY-84252</AgreementNumberFull>
<AgreementNumberAbbr>WY84252</AgreementNumberAbbr>
<LineOfBusiness>F</LineOfBusiness>
<CompanyCode>0005</CompanyCode>
<UniqDigit/>
<StateCode/>
... (9 Replies)
Hi.
I need help with a little script that will be used to move some files to their parent directory, delete the directory, rename one file in the parent directory and delete another, then continue to the next.
Here's an example:
/var/media/Music/Genesis/1970 album - Trespass (2008 Box -... (4 Replies)
Hi,
I need someone's help in writing a shell script. Since am very new i am stuck .
I have 2 files in the same dir.
==============================================
FileA
Table1~07/07/2009 00:00:00~4
Table1~07/06/2009 00:00:00~41
Table1~07/08/2009 00:00:00~4
... (8 Replies)
Hi,
I am using the command find /apps/qualdb/gpcn/scripts/cab_outbound/archive -name 'z*' -mtime +28 -exec rm {} \;
in unix command prompt
for deleting the files in my unix system under the specfied folder. It was succesfull.
But when i running this command inside a shell script name... (2 Replies)
Task:
Short Description: To find the files in a particular directory for the previous day, sort them by date and time and e-mail it across to a particular id.
And the time is divided into eight fields and based on the time the respective field should be updated with the flag 1.
Eight... (7 Replies)
I am trying to create a Korn Shell script to be run every 5-10 minute from a crontab. This script needs to look for log files (transaction_<date>.log). If there are more than 5 such files, it needs to delete all but the most current 5. How often these files are create varies - can be every minute... (2 Replies)
i have the following problem:
use shell script:
Two directories have to be searched for files havin the same name.
then delete these files from one of these directories.
the directory names have to be accepted as command line arguments.
what i have done till now is:
1. run a loop... (1 Reply)