1

I'm wanting to find multiple files as in

 find /etc/ /usr/ -type f,d -size +1k -exec ls -slah {} /; -exec rm -riv {} +

My question to you is how can I delete only the file size 5k and below with the -exec option

1 Answers1

3

If I understand your question correctly, you want to:

  1. Look for files under /etc and /usr
  2. Select only those files which are under 5k in size
  3. Delete them

In that case, what you want is this:

find /etc /usr -type f -size -5k -delete

Notice that there is no need for -exec, since you can simply use the -delete option.

In your question you wrote -size +1k. Did you mean to ask about finding files which are between 1k and 5k in size? If that was the case, then you can simply specify the -size option twice:

find /etc /usr -type f -size +1k -size -5k -delete
d a i s y
  • 5,511