6 ms·
the truncation is a poor example. - it creates the file if it does not exist, not merely truncate. as a tutorial kind of blog post this incomplete description
by jiveturkey 2mo ago
the truncation is a poor example.
- it creates the file if it does not exist, not merely truncate. as a tutorial kind of blog post this incomplete description matters IMO.
- it would work the same without the colon (similar for default variable assignment examples). we generally strive not to have "extra" things, like useless use of cat.
- educationally it's useful to demonstrate that redirection, like parameter expansion, works before the command executes (the null command in this case), but the article doesn't explain that at all!
otherwise i <3 this article. some uses of colon i had never thought of or seen before. like file truncation, not sure i'd use them but it was cool to see them.
- refp 2mo agoHey jiveturkey, author here! I agree with you, and for what it's worth the truncation snippet is very much tongue-in-cheek much like `( : >> output ) && echo "is writable"`. I wasn't expecting anyone to actually use these in Prod, rather I aimed to show what can be done with a command designed to.. do nothing (crazy). Happy you enjoyed the article, and thank you!
- deleted 2mo ago[deleted]