WebFaction
Community site: login faq

I have a temp directory which has a lot of .pdf generated files via my application (now its more than 1GB).
How do I remove / delete them safely ? I don't want to do rm -f *

asked 28 Jul, 12:15

anjanesh's gravatar image

anjanesh
56615
accept rate: 25%


You can also do rm -i *.pdf which will actually prompt you for confirmation before each deletion. Not bad if you have just a handful of files; it might get repetetive if you have a lot of files to delete.

permanent link

answered 30 Jul, 22:57

kjodle's gravatar image

kjodle
635
accept rate: 40%

I'm not sure what your concern is here. If the directory in question contains only the PDF files that you want to delete, then "rm -f *" is a reasonable approach to deleting the files.

If you want to be sure that the operation is limited only to PDF files, then you can do "rm -f *.pdf"

permanent link

answered 28 Jul, 19:42

seanf's gravatar image

seanf ♦♦
11.7k21333
accept rate: 37%

Is this by chance safer ? find . -name "*.pdf" -type f -delete

(29 Jul, 06:13) anjanesh anjanesh's gravatar image

The only thing that makes rm -f * unsafe is running it in the wrong place. If the directory contains only the PDFs you want to delete, then it's perfectly fine to run in that directory. "find . -name "*.pdf"-type f -delete and rm -f *.pdf are functionally the same - they will delete files with the .pdf extension in the directory in which the command is run.

(29 Jul, 14:26) maryh ♦♦ maryh's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×14

question asked: 28 Jul, 12:15

question was seen: 104 times

last updated: 30 Jul, 22:57

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM