1

I have been using the following code for the longest on a system I took over:

find /mnt/tmp -atime +91 -exec rm -f {} \;

However, researching further I see everyone saying the curly braces should be enclosed in single quotes like below:

find /mnt/tmp -atime +91 -exec rm -f '{}' \;

I have never had issues before, but I am curious of any negative impact not using the single quotes might have. Also curious if it varies across linux flavors?

The servers are Ubuntu.

Damainman
  • 1,045
  • 5
  • 16
  • 26

1 Answers1

1

The impacts you're speaking of will show up if you have "special" characters in your filenames (as distinct from regex-type special characters). The most obvious would be if you have a file named foo /* - your rm command would go and remove foo then /* without the single quotes, which you probably wouldn't want.

John
  • 9,070
  • 1
  • 29
  • 34
  • Ahh thanks. Yes currently the files are all alphanumeric with no spaces or special characters, which would explain why I haven't ran into any issues. Thank you. – Damainman Nov 21 '13 at 19:28