-1

I'm trying to get my Shell script working, but I keep getting: find: missing argument to '-exec'

#!/bin/sh
echo Hello World
find ./public_html/var/session/ -type f -name "sess*" -mtime +30 -exec rm -f {} \;
echo DONE

I've been trying to find help in these solutions but sadly none of them have solved my problem.
Shell script - find: missing argument to `-exec'
find: missing argument to -exec

oguz ismail
  • 1
  • 16
  • 47
  • 69
Carsten Løvbo Andersen
  • 26,637
  • 10
  • 47
  • 77

1 Answers1

1

Another option not involving -exec is to pipe the result to xargs and then rm on it:

find ./public_html/var/session/ -type f -name "sess*" -mtime +30 | xargs rm -f

man xargs

Note: xargs supports executing in parallel with -P command, see man page.

brokenfoot
  • 11,083
  • 10
  • 59
  • 80