Hi,
I have two set of files in a directory called /tmp/backup. I want to write a script to remove the oldest of these two, so that there is space available for a newer similar backup file.
For example,
I have
/tmp/backup/dbbackup_dbname_121223112 (oldest)
/tmp/backup/dbbackup_dbname_321445563 (latest)
Now I want my script to remove the oldest
/tmp/backup/dbbackup_dbname_121223112
and if the same script is run next day it should remove
/tmp/backup/dbbackup_dbname_321445563
I am thinking about a command in script such as below
(not sure about this, please advice)
Thanks.
Last edited by joeyg; 03-19-2012 at 01:16 PM..
Reason: Please wrap code and data with CodeTags
ls -1tr | head -1
databasefiles_DB_r8n64lfn_11112_20120317
But what if I have more than one old file as below? Your command would give me the single oldest file, but in my situation I have bunch of old files as shown below. If I run the script today (Mar 19), I want to remove all the files created on Mar 17. Please see below.
Thanks again.
Last edited by methyl; 03-19-2012 at 02:28 PM..
Reason: Code tags & some line-up
Apart from the fact that this backup appears to start on the 17th and finish on the 18th, there also seems to be two files missing (sequence 11118 and 11120).
It would be logical to treat the start of the Oracle database online backup as a marker point, not just the date. The Oracle database backup and the subsequent archive logs are what you need to recover the database data. You would only delete the old online backup set after a successful offline backup of those files. Does your offline backup start after the online backup finishes?
I have below file. I want to remove space at begining of every line and then after also remove blank line from file.
I use below code for each operation.
sed -e 's/^*//' < check.txt > check1.txt
sed '/^\s*$/d' < check1.txt > check2.txt
above code not remove all the space... (12 Replies)
hi i need shell scrip to pick the oldest file...
i.e i need a script to pick the oldest file
I had input files in my input folder that are created on saturday,monday,tuesday .. i want a script such that first the script should pick saturday file ,then monday and then file created on... (5 Replies)
Hi All,
I've a csv file in which the record is getting break into 1 line or more than one line. I want to combine those splits into one line and remove the unwanted character existing in the record i.e. double quote symbol ("). The line gets break only when the record contains double... (4 Replies)
How can i remove a file using shell script when its size exceeds 10MB. Given that file is located in different location to the shell script where it is running? (4 Replies)
How can I remove all data that contain domain e.g zzgh@something.com, sdd@something.com.my and gg@something.my in one file? so that i only have data without the domain in the file.
Here is the file structure "test.out"
more test.out
1 zzztop@b.com
1 zzzulll
1 zzzullll@s.com.my
... (4 Replies)
Hi,
I am pasring a file line by line. I need to check each field in line and remove particular line.
input file lines are,
02;ABC;PQR
03;aaa;rrr
04;ABC;ggg
09;eee;ABC
04;lmn;stu
I am looking for line containing "ABC" as field value. Now How can I remove this line from input file... (7 Replies)
Hello Folks,
I want to get the results from a SQL query which needs to be exported to a .txt file.
My Script is something like
#!/bin/ksh
db2 connect to DATABASE user user_name using pwd;
touch test.txt
isResult=0;
isResult= `db2 -x select 'ABC',COL_B from TABLE_A WHERE COL_B=CONDITION`... (6 Replies)
Hi,
I am writing a shell script that needs to remove duplicate lines within a file by category.
example:
section a
a
c
b
a
section b
a
b
a
c
I need to remove the duplicates within th category with out removing the duplicates from the 2 different sections (one of the a's in section... (1 Reply)
Hi,
I have a script that works on a unix box but am trying to get it working on a linux box that uses shell. I am not a programmer so this is proving harder than I imagined. I made some changes and ended up with the script below but when I run it I get the following messages. Any help would be... (4 Replies)