3 ms·
You may also create new empty files by saying `touch filename`. This saves three keystrokes (which includes an annoying `>` symbol, requiring the shift key) as
by memset 15y ago
You may also create new empty files by saying `touch filename`. This saves three keystrokes (which includes an annoying `>` symbol, requiring the shift key) as compared to the aforementioned `cat` method!
- Ives 15y agoOr, at least when running Bash (possibly sh, didn't try), just >foo also works to create file "foo".
- koenigdavidmj 15y agoThat does not work, but :>foo (the happy file creation operator) does.
- avar 15y agoWhat do you mean it doesn't work? ">file" will work on all POSIX shells, it even works on Solaris /bin/sh! Also ":>" is not an operator, it's ":" (a built-in command that does nothing and returns true) and a redirection.
- waitwhat 15y agoLike the grand-parent, I have definitely used a Unix variant (CX/SX?) which required a command to do redirection.
- koenigdavidmj 15y agoIt was a joke to call it an operator.
- bnegreve 15y agowhat do you mean? "cat > file" allows you to create simple text file not just empty files. As long as you don't need advanced editing, it is the quickest way to do it (well I think).
- memset 15y agoYou are correct; my comment solves a different problem than the one in the article!
- s-phi-nl 15y agoYou can also use 'echo "hello" > file'
- veyron 15y agotechnically the equivalent is echo -n > file