How can I create a file named "-file" using command line in Linux?
Sometimes you can slip and create a file whose name starts with a dash ( - ), like -output or -f. That's a perfectly legal filename.
Press Option+Shift+hyphen . Linux desktop environment. Enable the Compose key (instructions for doing that vary depending on your flavor of Linux—for examples, see Linux Keyboard Shortcuts For Text Symbols). After the Compose key is enabled, you can create an em dash by typing the Compose key followed by three hyphens.
Dash (-) character at the end of the commands is a popular convention to refer stdin or stdout. Dash is not a special character for filesystem or kernel. When -- character seen, shell thinks that optional arguments for command itself finished and doesn't make option parsing anymore.
In bash --
is a flag that is interpreted as "nothing after this should be taken as a flag", so -
is no longer parsed as an option.
touch -- -file
specify a path in front of it, e.g. ./-file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With