Sponsored Content
Top Forums Shell Programming and Scripting Delete folder in a directory which are two months old Post 302667367 by pamu on Friday 6th of July 2012 07:24:20 AM
Old 07-06-2012
below code will give directories older than two months, means not JUN and not JUL.

Code:
prev_mth=`date --date="last month" +%b`
curr_mth=`date "+%b"`
ls -lth | grep "^d" | awk -v CM=$curr_mth -v PM=$prev_mth  ' $6 != CM  { if ( $6 != PM ) print $9 }'

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Delete database table based on months using script.

HI All, Newbie here. I have a script which generates the tables in teradata database with time stamp like below.I want to add some more code to delete the archive tables which are 2months old. . $HOME/.profile t_name=$1 procdate=`date +%y%m%d` log_dir=$Folder/log tab=`echo... (0 Replies)
Discussion started by: Maverick79
0 Replies

2. Shell Programming and Scripting

Delete files older than 3 months.(read date from the name of the file)

Guys, My log files stored in the date format format below(log_20080714072942): TIMESTAMP=`date +%Y%m%d%H%M%S` LOG=/log/log_${TIMESTAMP}.log I'm looking for a shell script which deletes all files which is older than 3 months from today. Regards, Bhagat (3 Replies)
Discussion started by: bhagat.singh-j
3 Replies

3. Shell Programming and Scripting

Delete 6 months old files

Hi, Iam trying to delete 6 months old files. Iam using the following script -ctime +190 -type f -exec echo rm {} \; Iam getting an error saying -ctime not found. (6 Replies)
Discussion started by: Sompalle Jalaja
6 Replies

4. UNIX for Dummies Questions & Answers

single line command to delete a 6 months old file

i had this scenario where i need to delete a file that is 6 months old which is no longer needed. basically the filename is in the format of PCARDDAILYmmddyyyy.txt where the mm is the month, dd is the day, and yyyy is the year. e.g. PCARDDAILY05262009.txt PCARDDAILY05252009.txt ... (6 Replies)
Discussion started by: wtolentino
6 Replies

5. Shell Programming and Scripting

Looking for improvement to script that compresses a directory that is 2 months old

I write reports daily to a directory that is named with the month and year. I wanted to compress all but the last two months worth of these directories to save space. I am going to cron a job to run on the first of each month to do this clean up. I didn't have zip/unzip on my AIX environment so... (0 Replies)
Discussion started by: slatoms
0 Replies

6. Shell Programming and Scripting

Delete 2 months before old files when we get alarm directory size > 90%

Please Help me Question: - we manually moving/removing old files, when we are getting alarm as /dir1/dir2 size greater than 90%. we manually moving/removing old files and reduce the file size to less than 90% - I want to delete all 2months before old files once we get the thresh hold >= 90%... (3 Replies)
Discussion started by: piyus
3 Replies

7. Red Hat

Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months

ENVIROMENT Linux: Fedora Core release 1 (Yarrow) iPlanet: iPlanet-WebServer-Enterprise/6.0SP1 Log Path: /usr/iplanet/servers/https-company/logs I have iPlanet log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I... (7 Replies)
Discussion started by: zachs
7 Replies

8. Shell Programming and Scripting

Deleting files and directory's older than 3 months

I have a qnap TS259 that is running ubuntu. Have successfully setup back scripts that are initiated by cron. I would like to create a couple scrypts that would operate on the recycle bins for both drives. Just want to be able to run the script manually that would walk through both directories... (13 Replies)
Discussion started by: mackconsult
13 Replies

9. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

10. Shell Programming and Scripting

Delete oldest folder based on folder named as date

Hi, I have a script doing backup to synology server, the script create new folder each day with the date as being folder name i.e. 2018-07-30. Just before creating the new folder I want the script to find the oldest folder from the list and delete it including its content. for example... (3 Replies)
Discussion started by: humble_learner
3 Replies
SWISS::DTs(3pm) 					User Contributed Perl Documentation					   SWISS::DTs(3pm)

Name
       SWISS::DTs

Description
       SWISS::DTs represents the DT lines within an Swiss-Prot + TrEMBL entry as specified in the user manual
       http://www.expasy.org/sprot/userman.html .

Inherits from
       SWISS::BaseClass.pm

Attributes
       "CREATED_date"
	   Creation date

       "ANN_date"
	   Last annotation update

       "SQ_date"
	   Last Sequence update

       "CREATED_rel"
	   Created for release

       "ANN_rel"
	   Last annotation for release

       "SQ_rel"
	   Last sequence update for release

       "ANN_version"
	   Version number for entry annotation

       "SQ_version"
	   Version number for sequence

Methods
   Standard methods
       new
       fromText
       toText
       sort

   Writing methods
       set_Created ($date, $release)
       set_AnnotationUpdate ($date, $release[, $version])
       set_SequenceUpdate ($date, $release[, $version])

TRANSITION
The format of the DT line will change in early 2004 from: DT 01-JUL-1993 (Rel. 26, Created) DT 01-JUL-1993 (Rel. 26, Last sequence update) DT 28-FEB-2003 (Rel. 41, Last annotation update) to: DT 01-JUL-1993, integrated into UniProtKB/Swiss-Prot. DT 01-JUL-1993, sequence version 36. DT 28-FEB-2003, entry version 54. This module supports both formats. To convert an entry from the old to the new format, do: $entry->DTs->CREATED_rel("UniProtKB/Swiss-Prot"); $entry->DTs->ANN_version(54); $entry->DTs->SQ_version(36); perl v5.10.1 2008-07-11 SWISS::DTs(3pm)
All times are GMT -4. The time now is 07:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy