How to create empty file in Linux

https‮l.www//:‬autturi.com
How to create empty file in Linux

To create an empty file in Linux, you can use the touch command. The touch command is a standard Unix command that is used to create a new empty file or to update the timestamps of an existing file.

To create a new empty file, you can use the following syntax:

touch filename

For example, to create a new empty file called myfile.txt, you can use the following command:

touch myfile.txt

This will create a new empty file with the name myfile.txt in the current directory.

You can also create multiple empty files at once by specifying a list of filenames:

touch file1.txt file2.txt file3.txt

Keep in mind that you will need to have appropriate permissions to create a new file in the current directory. You may need to use the sudo command to gain sufficient privileges.

You can use the ls command to list the files in the current directory and verify that the new empty file has been created.

Note that the touch command will not create a file if a file with the same name already exists. To create a new empty file with the same name as an existing file, you can use the > operator to overwrite the existing file with an empty file. For example:

touch myfile.txt
echo "" > myfile.txt

This will create a new empty file called myfile.txt and overwrite any existing file with the same name.

Created Time:2017-10-16 14:38:45  Author:lautturi