DEV Community

Cover image for Create File in bash Terminal
Bigtechsol.com
Bigtechsol.com

Posted on

Create File in bash Terminal

Knowing Linux is a widely used server-side operating-system 96.3% of the world’s top 1 million servers run only on Linux. Only 1.9% use Windows servers and 1.8% – FreeBSD servers. Why people love Linux? Linux is open-source And free Today Our top is How to create a new directory and file is an important skill for anyone using Linux. We can Create Files in bash either from the command line or from the Linux file manager.

Depending on what you want the file to contain:
touch /path/to/file for an empty file
somecommand > /path/to/file for a file containing the output of some command.
eg: grep --help > randomtext.txt
echo "This is some text" > randomtext.txt
nano /path/to/file or vi /path/to/file (or any other editor emacs,gedit etc)
It either opens the existing one for editing or creates & opens the empty file to enter, if it doesn't exist

Top comments (0)