Delete File Based On Date


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Delete File Based On Date
# 1  
Old 07-30-2008
Delete File Based On Date

Hi Xpert Out There

I have a lots of file in this path :

-rw-r----- 1 oracle dba 3954176 Dec 21 2006 1_2008.dbf
-rw-r----- 1 oracle dba 887808 Dec 21 2006 1_2009.dbf
-rw-r----- 1 oracle dba 143872 Dec 21 2006 1_2010.dbf
-rw-r----- 1 oracle dba 33792 Dec 21 2006 1_2011.dbf
-rw-r----- 1 oracle dba 1536 Dec 21 2006 1_2012.dbf
-rw-r----- 1 oracle dba 1024 Dec 21 2006 1_2013.dbf
-rw-r----- 1 oracle dba 31744 Dec 21 2006 1_2014.dbf
-rw-r----- 1 oracle dba 104857088 Dec 22 2006 1_2015.dbf
-rw-r----- 1 oracle dba 104857088 Dec 24 2006 1_2016.dbf
-rw-r----- 1 oracle dba 1048064 Dec 24 2006 1_2017.dbf
-rw-r----- 1 oracle dba 104857088 Dec 25 2006 1_2018.dbf
-rw-r----- 1 oracle dba 1048064 Dec 25 2006 1_2019.dbf

Now i want to delete all file date on 2006 with single command. How to do this???
By the way, i'm using solaris 9....TQ in advance
# 2  
Old 07-30-2008
One way,

Code:
ls -l | /usr/xpg4/bin/awk '$8==2006 && /^-/ && $0=$NF' | xargs rm

# 3  
Old 07-30-2008
Tq rubin....
Smilie
# 4  
Old 07-30-2008
Or you can use 'find' and pipe the output to the 'xargs rm' rubin provided.
but since these files most likely are database files you might want to consult your local dba if he/she for some reason wants to keep them :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. HP-UX

HP/UX command to pull file name/date based on date

HI, Can anyone tell me how to pull the date and file name separated by a space using the find command or any other command. I want to look through several directories and based on a date timeframe (find -mtime -7), output the file name (without the path) and the date(in format mmddyyyy) to a... (2 Replies)
Discussion started by: lnemitz
2 Replies

3. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

4. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

5. Shell Programming and Scripting

delete a row in csv file based on the date

Hi, I have a csv file with old data..i need to have only last 30 days from the current dateof data in the file.The fourth field in the file is a date field.i need to write a script to delete the old data by comparing the the fourth field with the (current date -30).I need to delete the rows in... (2 Replies)
Discussion started by: pals70423
2 Replies

6. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

7. Shell Programming and Scripting

Delete log file entries based on the Date/Timestamp within log file

If a log file is in the following format 28-Jul-10 ::: Log message 28-Jul-10 ::: Log message 29-Jul-10 ::: Log message 30-Jul-10 ::: Log message 31-Jul-10 ::: Log message 31-Jul-10 ::: Log message 1-Aug-10 ::: Log message 1-Aug-10 ::: Log message 2-Aug-10 ::: Log message 2-Aug-10 :::... (3 Replies)
Discussion started by: vikram3.r
3 Replies

8. UNIX for Dummies Questions & Answers

Delete lines with duplicate strings based on date

Hey all, a relative bash/script newbie trying solve a problem. I've got a text file with lots of lines that I've been able to clean up and format with awk/sed/cut, but now I'd like to remove the lines with duplicate usernames based on time stamp. Here's what the data looks like 2007-11-03... (3 Replies)
Discussion started by: mattv
3 Replies

9. Shell Programming and Scripting

Delete block of text in one file based on list in another file

Hi all I currently use the following in shell. #!/bin/sh while read LINE do perl -i -ne "$/ = ''; print if !m'Using archive: ${LINE}'ms;" "datafile" done < "listfile" NOTE the single quote delimiters in the expression. It's highly likely the 'LINE' may very well have characters in it... (3 Replies)
Discussion started by: Festus Hagen
3 Replies

10. UNIX for Dummies Questions & Answers

Based on the permision in the dir can i delete the file

All, I am having a directory as drwxrwsr-x 3 intermec intermec 10240 Jan 8 09:07 intermec inside the directory . the files are like cd -rw-r----- 1 intrmc01 intermec 5226 Dec 2 15:03 AST07356.txt -rw-r----- 1 intrmc01 intermec 5025 Dec 2 12:51... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies
Login or Register to Ask a Question