Moe Moe - 4 months ago 25
Bash Question

What command makes a new file in terminal?

if mkdir creates a new directory, what creates a new file. for example "something.text".

i tried couple of commands mkdir (FileName) -- works fine. but didn't know how to create a new file inside a directory. I know that i can always go to my project folder then create my new file but i want to know how to do that using terminal to increase productivity. I appreciate it.



On Linux there are mutiple options

The typical used one is touch

touch bar.txt

However you may also use echo if you want to create and write to the file right away

The following command tells to create bar.txt and put foo inside of it

echo foo > bar.txt

You may also use >> which appends to an existing file

The following command puts bar at the end of bar.txt, in a other words, bar will display after foo inside bar.txt

echo bar >> bar.txt