Hone

Lessons · Terminal · making an empty file

Making an empty file

touch name creates an empty file if there is none, and only updates the modified time if there is one.

Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.

What it is for

You often need a file to exist before an editor, a script or a tool will accept it: a log, a config, a placeholder.

How to think about it

touch to create, ls to confirm, then fill it with an editor or with echo and a redirect.

Worked example

touch todo.txt
An empty file appears.
ls
todo.txt.
wc -c < todo.txt
0: no bytes in it yet.

Your turn

Create an empty notes.md.

 notes.md

The trap

Expecting touch to open an editor. It does not; it only makes the file exist.

Practise making an empty file on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.