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 trialOmar Farag
4,573 PointsMake files in a UNIX console
I know I can make directories with the mkdir command, but I don't know how to make files. Any help?
Alexander Davison
65,469 PointsI'd use nano. Just type nano into the console, and type out your file content, and to save, first exit with ^X (Ctrl-X) then press Y. Next, you can type the file name. Hope that might help!
For more detail, try this:
$ nano
<Some thing pops up>
$ ls
cake cake cake <whatever your file is>
$ cat <whatever your file is>
cake cake cake cake
$ rm <whatever your file is>
Also, if you want to edit a file, do this:
$ nano <whatever your file is>
3 Answers
Sue Dough
35,800 Points@xela888 answer is not efficient. What if he wants to create 50 files? What if he doesn't want to nano and have to edit?
:)
Just do this mate:
touch hello.txt hello2.txt hello3.txt
Also @xela888 you can specify a file with nano like this to avoid the extra step:
nano hello.txt
It will then make that file.
Alexander Davison
65,469 PointsHmm... I haven't ever learned that! Thank you for explaining.
Omar Farag
4,573 PointsSo "touch" can create multiple files at once? Thanks
Sue Dough
35,800 PointsYes indeed. Very helpful.
If you want to see all the options touch can do just type this to see the manual:
man touch
Omar Farag
4,573 Pointsok, thanks
Alexander Davison
65,469 PointsNo problem!
Erving Velez
300 PointsThat is a lot of cake. :-)
Alexander Davison
65,469 PointsYum yum. Just to fill in the text I decided to use "cake cake cake"
Omar Farag
4,573 PointsOmar Farag
4,573 PointsAlso, can someone explain why, when I execute the "exit" command when logged in as treehouse, the shell goes blank and I can't type anything? Thanks in advance.