First, some minor fixes:
#!/bin/sh
logs=/cygdrive/l
find "$logs" -name '*system.log*' -mtime +14 -exec rm -- {} +
...but those won't address your real problem (the one causing -exec
to report an error), which is almost certainly the presence of DOS newlines in your script.
find -exec
reports the error in question when it doesn't see an argument containing only the exact string ;
. Outside quotes, \;
should be that argument -- but it can be different if your file has hidden characters. And a DOS text file will appear to have hidden characters when opened by a program expecting a UNIX text file, because the two formats have different line separators.
To fix this, open the file in a native-UNIX editor such as vim, run :set fileformat=unix
, and save it; or use dos2unix
to convert it in-place.