Sometimes creating a file empty or with a little content can be important. In this post, we will look at how to create a file from the command-line interface. Here are alternative ways to create files.
The touch command is the first choice for creating an empty file with the current user ownership.
$ touch ex1
As we can see the owner of the file is
ismail and the group of the file is
ismail. The permissions are set according to the
umask value which is 664 in this case.
The echo command is a very useful command to put the string into the standard output. We redirect our output to a file new file will be created.
$ echo "" > ex2
We can provide some text data to put into a newly created file.
$ echo "Some data" > ex3
Cat is a command especially created for concatenate files and print on the standard output.
$ cat > ex4
After putting command we should press CTRL+d to exit from input mode.