DEV Community

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

Posted on

2

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay