Sponsored Content
Operating Systems Linux Red Hat Delete files older than 1week(dates need to be calculate based on file name) Post 302999610 by Agoyals1986 on Friday 23rd of June 2017 08:57:30 AM
Old 06-23-2017
Delete files older than 1week(dates need to be calculate based on file name)

Objective: We have multiple files in a folder and we want to delete all files except for last 1 week files.

Note: We are copying these files from original location to this temporary location. So time shown for these files are time when we copied to this location. Not that when file was created.

Files are:
Code:
-rw-rw-r-- 1 root root   3730573 Jun 23 14:06 tps-20170516192956200-10248.tps
-rw-rw-r-- 1 root root  34803468 Jun 23 14:06 tps-20170516195930440-2586.tps
-rw-rw-r-- 1 root root  33504240 Jun 23 14:06 tps-20170517231247323-2586.tps
-rw-rw-r-- 1 root root  33247339 Jun 23 14:07 tps-20170519030152674-2586.tps
-rw-rw-r-- 1 root root  33283294 Jun 23 14:07 tps-20170519030525811-2586.tps
-rw-rw-r-- 1 root root  33211241 Jun 23 14:07 tps-20170520120924116-26089.tps
-rw-rw-r-- 1 root root  35135540 Jun 23 14:07 tps-20170521203131446-45475.tps
-rw-rw-r-- 1 root root  27263002 Jun 23 14:07 tps-20170522171753527-45475.tps
-rw-rw-r-- 1 root root  34145738 Jun 23 14:07 tps-20170522180142517-45475.tps
-rw-rw-r-- 1 root root  33248824 Jun 23 14:08 tps-20170523210831497-45475.tps
-rw-rw-r-- 1 root root  33497660 Jun 23 14:08 tps-20170523223946192-45475.tps
-rw-rw-r-- 1 root root  33140593 Jun 23 14:08 tps-20170524004838503-45475.tps
-rw-rw-r-- 1 root root  33700101 Jun 23 14:08 tps-20170524183206292-45475.tps
-rw-rw-r-- 1 root root  33285239 Jun 23 14:08 tps-20170525004909816-45475.tps
-rw-rw-r-- 1 root root  18466717 Jun 23 14:09 tps-20170525171625377-45475.tps

The date of the file can be found in file name itself.

tps-20170525171625377-45475.tps = 2017-05-25

Query: In above example we have files from 16-05-2017 to 25-05-2017. How can keep files only for last seven days i.e. 19th to 25th may and remove rest of them.

Thanks
Ankit
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete files older than 7 days

can anyone tell me how I would write a script in ksh on AIX that will delete files in a directory older than 7 days? (1 Reply)
Discussion started by: lesstjm
1 Replies

2. UNIX for Dummies Questions & Answers

How can I delete files older than 7 days?

I will like to write a script that delete all files that are older than 7 days in a directory and it's subdirectories. Can any one help me out witht the magic command or script? Thanks in advance, Odogboly98:confused: (3 Replies)
Discussion started by: odogbolu98
3 Replies

3. Shell Programming and Scripting

how to delete the files which are the 30 min older...?

Hi all, i have a simple question that i want to find out the 30 minutes older files and delete those files from the particular location(Folder) Generally for this purpose used to retreive the files with "atime" command For example: find and delete the 2 days older log files use this below... (2 Replies)
Discussion started by: psiva_arul
2 Replies

4. 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

5. UNIX for Dummies Questions & Answers

Delete files older than 30 days

This is driving me crazy. How can I delete files in a specifc directory that are over 30 days old? Thanks in advance. (3 Replies)
Discussion started by: tlphillips
3 Replies

6. Shell Programming and Scripting

Delete files older than today

is it -mtime +1 as i need all files older than today to be deleted (6 Replies)
Discussion started by: dinjo_jo
6 Replies

7. Shell Programming and Scripting

To delete files older than 24 hrs

I have to retain only 1 day files in my system an I have to delete all the other files which are older than 24 hrs. Please let me know the option I have to give in the find -mtime command. (3 Replies)
Discussion started by: rajesh8s
3 Replies

8. UNIX for Dummies Questions & Answers

How to delete all the files older than a date?

Hi, I need a command for deleting all the compress files *.Z that are older than the current date - 5 days. Basically I have a directory where daily I meet some back up files and I want to remove automatically the ones 5 days (or more) older than the current date. How can I write a 'rm' command... (1 Reply)
Discussion started by: Francy
1 Replies

9. Shell Programming and Scripting

List and Delete Files which are older than 7 days, but have white spaces in file name

I need to list and delete all files in current older which are olderthan 7 days. But my file names have white spaces. Before deleting I want to list all the files, so that I can verify.find . -type f -mtime +7 | xargs ls -l {} But the ls command is the working on the files which have white... (16 Replies)
Discussion started by: karumudi7
16 Replies
gdaltransform(1)					      General Commands Manual						  gdaltransform(1)

NAME
gdaltransform - gdaltransform transforms coordinates SYNOPSIS
gdaltransform [--help-general] [-i] [-s_srs srs_def] [-t_srs srs_def] [-to "NAME=VALUE"] [-order n] [-tps] [-rpc] [-geoloc] [-gcp pixel line easting northing [elevation]]* [srcfile [dstfile]] DESCRIPTION
The gdaltransform utility reprojects a list of coordinates into any supported projection,including GCP-based transformations. -s_srs srs def: source spatial reference set. The coordinate systems that can be passed are anything supported by the OGRSpatialReference.SetFromUserInput() call, which includes EPSG PCS and GCSes (ie. EPSG:4296), PROJ.4 declarations (as above), or the name of a .prf file containing well known text. -t_srs srs_def: target spatial reference set. The coordinate systems that can be passed are anything supported by the OGRSpatialReference.SetFromUserInput() call, which includes EPSG PCS and GCSes (ie. EPSG:4296), PROJ.4 declarations (as above), or the name of a .prf file containing well known text. -to NAME=VALUE: set a transformer option suitable to pass to GDALCreateGenImgProjTransformer2(). -order n: order of polynomial used for warping (1 to 3). The default is to select a polynomial order based on the number of GCPs. -tps: Force use of thin plate spline transformer based on available GCPs. -rpc: Force use of RPCs. -geoloc: Force use of Geolocation Arrays. -i Inverse transformation: from destination to source. -gcppixel line easting northing [elevation]: Provide a GCP to be used for transformation (generally three or more are required) srcfile: File with source projection definition or GCP's. If not given, source projection is read from the command-line -s_srs or -gcp parameters dstfile: File with destination projection definition. Coordinates are read as pairs (or triples) of numbers per line from standard input, transformed, and written out to standard output in the same way. All transformations offered by gdalwarp are handled, including gcp-based ones. Note that input and output must always be in decimal form. There is currently no support for DMS input or output. If an input image file is provided, input is in pixel/line coordinates on that image. If an output file is provided, output is in pixel/line coordinates on that image. Image RPC Example Simple reprojection from one projected coordinate system to another: gdaltransform -s_srs EPSG:28992 -t_srs EPSG:31370 177502 311865 Produces the following output in meters in the 'Belge 1972 / Belgian Lambert 72' projection: 244510.77404604 166154.532871342 -1046.79270555763 Image RPC Example The following command requests an RPC based transformation using the RPC model associated with the named file. Because the -i (inverse) flag is used, the transformation is from output georeferenced (WGS84) coordinates back to image coordinates. gdaltransform -i -rpc 06OCT20025052-P2AS-005553965230_01_P001.TIF 125.67206 39.85307 50 Produces this output measured in pixels and lines on the image: 3499.49282422381 2910.83892848414 50 AUTHORS
Frank Warmerdam warmerdam@pobox.com, Jan Hartmann j.l.h.hartmann@uva.nl GDAL
Tue Sep 18 2012 gdaltransform(1)
All times are GMT -4. The time now is 08:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy