- (Hyphen) and – (Dash) Are Not the Same
Feb 21, 2014
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?
- Turn off AutoCorrect & AutoFormat options in Outlook
- Start with a Plain Text formatted email
- Write the commands in Notepad or Notepad++ and attach the text file to the email
*It does not really ignore it, rather, it interprets it as a verbatim file name you want to find instead of wild card search.