Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Depends a bit on your shell. That works great in bash. Other shells have different semantics. For example, zsh will wait for input until you type ^D or ^C and tcsh will complain about an invalid null command.

The variant I know that works identically in pretty much every shell I've ever tried is:

    :>myfile.txt
And if you don't want to overwrite the file if it exists:

    :>>myfile.txt


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: