Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSERGIO RODRIGUEZ
17,532 PointsHow do I create a new text file with console?
Jim explains how to create a new directory with the mkdir command, but, how about creating a new text file?
3 Answers
Geoff Parsons
11,679 PointsThere are a few ways to go about doing that. Some editors will allow you to open a file that doesn't exist and then create it when you save it. Another easy way would be with the touch command which will simply create a completely empty file with the name you give it:
gparsons at bolt in ~/example
$ ls
gparsons at bolt in ~/example
$ touch my_file.txt
gparsons at bolt in ~/example
$ ls
my_file.txt
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsSERGIO you can also do this:
nano testfile.txt
This creates the file with .txt type and automatically open the file in nano text editor.
It's totally up to you what do you want to do at that specific moment.
But normally you would you my way 'cos you create the file to edit it and write something in.
I never used the touch much.
Just a hint from my side :)
SERGIO RODRIGUEZ
17,532 PointsThanks for the hint!
SERGIO RODRIGUEZ
17,532 PointsSERGIO RODRIGUEZ
17,532 PointsThank You!!!
Sebastian Eguez
8,248 PointsSebastian Eguez
8,248 PointsI don't get this. What do you type exactly?