How, from a Terminal, do I make a plain text file and a folder?
MacOS – How to create a text file and a folder from terminal
macosterminal
Related Question
- MacOS – How to play a midi file from terminal
- MacOS – Text copied from Terminal with formatting in Mavericks (10.9), Yosemite (10.10), and El Capitan (10.11)
- Unable to cut from text edit and paste into terminal
- MacOS – Mac Terminal read each .txt file in folder and write (add) as text to specific file
- MacOS – How to use AppleScript to create a new Rich Text Format file from clipboard text
- MacOS – Copy files from Folder A to Folder B based on Text File C with bash
- How to programmatically get the Terminal scrollback text
Best Answer
A directory can be made using the mkdir command. To make a child directory of the current directory it's simply:
This will create a directory (shown as a folder in Finder) named
somechild
.A text file can be created in a few different ways. The simplest being the echo'ing of text and redirecting it in to a file like so:
This will create
myfile.txt
and its contents will be the stringThis is some text
.You can also use a command line text editor such as vim or emacs or nano to start a new text file. The following start a new text file and open them in the editor for each of the aforementioned editors:
The nano text editor is probably the most new-user-friendly of those three choices.