A LENGTHY REBOOT

By Richard Hsu
Latest | Archives | Contact | Others

- (Hyphen) and – (Dash) Are Not the Same

Linux find command ignores* –name (dash name) option and runs finding all files instead of exiting with an unknown parameter error.

Wrong command (with dash name option): find –name '*.dat' -exec rm {} \;

What I wanted it to do: Find all files matching *.dat wildcard and delete them What it does: Find all files in the directory and delete them, then throw an error message it could not find *.dat file or directory

Correct command (with hyphen name option): find -name '*.dat' -exec rm {} \;

I was typing the command in Outlook and the AutoCorrect feature changed - (hyphen) to – (dash). It was copy-pasted from the email to a Putty session executed causing undesired behaviour.

How to avoid this?

*It does not really ignore it, rather, it interprets it as a verbatim file name you want to find instead of wild card search.