How to delete files with certain ext?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to delete files with certain ext?
# 1  
Old 12-06-2007
How to delete files with certain ext?

Hi All,

How can I work on following request?

Delete all the html files older than 29th November from the path - /dding/ting/tong/unixyang/output
# 2  
Old 12-07-2007

Perform appropriate calulation to determine how many days ago 29th of november was, assign to $days.

find /dding/ting/tong/unixyang/output/ -name "*.html" -mtime $days -exec rm {} \;

To test, omit the "-exec rm {} \;" part of the above command
# 3  
Old 12-07-2007
find /dding/ting/tong/unixyang/output/ -name "*.html" -mtime $days -print
# 4  
Old 12-08-2007
Thanks everyone. It worked.

Could also tell me how can I do the request where user have asked to remove all files from certain directory with .html extension.
# 5  
Old 12-09-2007
Originally Posted by tonyvirk
Thanks everyone. It worked.

Could also tell me how can I do the request where user have asked to remove all files from certain directory with .html extension.
rm <directory>/*.html (eg rm /dding/ting/tong/unixyang/output/*.html)

Or if it should recurse to find all html files in subdirectories too:

rm -r <directory>/*.html (be careful to type this correctly)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

2. Shell Programming and Scripting

Log ext

I have a script that does log rotation, at 10000k, it will print out the logs as follows: << current log being written to at midnight it reverts back to : I want it to be able to go past date.9.log... (2 Replies)
Discussion started by: bigbenn
2 Replies

3. Shell Programming and Scripting

ext File

I have a log file that I want to extract the field name and the field value and write them to a text file for importation it a database table for reporting purposes. How can I extract the desired data from this file . Example: dbt_dbid=4 dbt_dbid is the field name 4 is the field value... (4 Replies)
Discussion started by: JolietJake
4 Replies

4. Shell Programming and Scripting

Recursively *.ext files using find

HI, Getting the syntax error " find: missing conjunction" for the below code D1_DIR=/x/y/z D1_NAME=file_name FILE_DIR=pset for file in `find ${D1_DIR}/${D1_NAME} -name "*\.${FILE_DIR}" /dev/null {} \;` do echo $file done #Trying to find all the files with *.pset... (5 Replies)
Discussion started by: cvsanthosh
5 Replies

5. Shell Programming and Scripting

du -s *.ext (total)

How would I get a total of a wildcard of files from the 'du' command? du -s *.pdf Result: 736 11mens_bracket.pdf 64 2011_NIT_Bracket_3_13_11.pdf 80 Doing more with Less part1.pdf 1064 Doing more with Less part2.pdf 28 Parkview_1309_Garage.pdf 3964 statsheet-bracket-2011.pdf Expected... (7 Replies)
Discussion started by: AlphaLexman
7 Replies

6. HP-UX

Limitation on *.ext

Is there a size limit when passing an argument using wildcards? I.E. when I pass an argument in the form (like) "ftp_auto *.txt" - is there a limitation on the size of UNIX expanding "*.txt" ? (1 Reply)
Discussion started by: vslewis
1 Replies

7. Shell Programming and Scripting

Shell script to rename files with .1,.2,.3 ....ext respectively

Hey Guys.... Just need some help as I am not proficient in Unix shell script... Doubt: --------------- Suppose there will be some of the following files inside a directory called OUT ... Path: - /appdb1/product/batch/rms/OUT files inside OUT directory:- POSU_75002_20090127_20090129035442... (4 Replies)
Discussion started by: satyajit007
4 Replies

8. Shell Programming and Scripting

checkingthe size of all the .txt , .ext files in all directories ..

hai, i am new to unix scripting & learning unix scripting and doing some assignments.... i have an assignment as follows, i want to check the size of the text file and .ext files in all directories, if any one of them is greater than 100mb , i have to display those files.. ... (2 Replies)
Discussion started by: G.K.K
2 Replies

9. UNIX for Dummies Questions & Answers

Help with a ext. modem on SCO 5.0.5

I am fully capable of reading a book to get the answers or looking to the web, but no one has the answer to this one. I had a Zoom 56K V34 Plus external modem (2836A) attached to my Unix box for about ten years without a flaw. This weekend I couldn't access the box remotely through the modem and... (0 Replies)
Discussion started by: scivic
0 Replies

10. UNIX for Dummies Questions & Answers

diff on compressed files with tar.gz ext

how can I find out what is the difference between two tar.gz files without uncompressing them. thank you. (7 Replies)
Discussion started by: rakeshou
7 Replies
Login or Register to Ask a Question