What's wrong with this 'find' command?

I am executing the following command (to find all files with .ts extension and deleting them):

find . -type f -name "*.ts" –delete

An error shows up:

find: paths must precede expression: `–delete'

What have I done wrong?


Solution 1:

You have typographic sign instead of minus (-).

Change your command to

find . -type f -name "*.ts" -delete

For complete syntax see man find:

ACTIONS
       -delete

        Delete files; true if removal succeeded. If the removal failed, an error message is issued.
        If -delete fails, find's exit status will be nonzero (when it eventually exits).
        Use of -delete automatically turns on the -depth option.


Be careful with copying and pasting commands from blogs and rich text processors. They may transform some typographic symbols to their plain text equivalents and vice versa.

Consider to use simple text editors for the notes next time - use plain text, Markdown or reStructuredText.

And as @AuxTaco mentioned - some blogs may rely on your copying to attack your computer.