Let's say I want to search a file for a string that begins with a dash, say "-something":
grep "-something" filename.txt This throws an error, however, because grep and other executables, as well as built-ins, all want to treat this as a command-line switch that they don't recognize. Is there a way to prevent this from happening?
--?--, there are exceptions (see here). The-eswitch is also mentioned in the comments section. I flagged this Q as duplicate, because I (still) think it is. You asked for a generic way and the--is a common way to handle such arguments. But that doesn't necessarily mean that this is the only way.