How to create a text file
Overview
touch creates an empty file if it does not exist; otherwise it updates timestamps. Redirection can create a file while writing command output into it.
Examples
touch notes.txt
printf '%s\n' 'First note' > notes.txt
printf '%s\n' 'Another note' >> notes.txt
cat notes.txt
Choose a method
touch filecreates an empty placeholder>creates or overwrites a file>>appends without removing existing contentnano fileis better for interactive multi-line editing
Safety
Redirection with > replaces existing contents without confirmation. Check the destination name first and use >> only when appending is intended.