Hope someone can help with this:
Am trying to delete session files on /tmp with this command:
find /tmp -name 'sess_*' -user Username -maxdepth 1 $CMD {} \;
but I got these errors:
find: warning: you have specified the -maxdepth option after a non-option argument -name, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.
find: paths must precede expression Usage: find [-H] [-L] [-P] [path...] [expression]
I looked for solutions over the web but could not find any. I have deleted other tmp files with other commands and wonder if that affected some volume or socket.
Thank you in advance
find
has three types of options: options that are used to match files (e.g. -name
, -user
), options that specify actions to perform on the matched files (-print
, -exec
), and options that control the overall behavior of the command (e.g. -maxdepth
, -xdev
). The third type must be put before the other two. So it should be:
find /tmp -maxdepth 1 -name 'sess_*' -user Username -exec $CMD {} \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With