Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to create a file in Linux from terminal window?

What's the most effortless approach to make a file in Linux terminal?
by

3 Answers

ninja01
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
iamabhishek
I think the most effortless way should be:

touch somefile.txt

Using the touch command.
kshitijrana14
Create the file using cat
$ cat > myfile.txt
Now, just type whatever you want in the file:
Hello World!
CTRL-D to save and exit

Login / Signup to Answer the Question.