What Is Touch Command and How to Use this command in linux
touch command

What Is Touch Command and How to Use this command in linux

Touch command is used in Linux/Unix operating system by which to create empty file and edit existing file. There are many other commands to create files in Linux such as vim, cat, nano etc. But in Linux/Unix it is more used to collect system logs, error messages, etc. through This commands. In this article, we will tell you about the Linux touch command, why and how it is used.

How to use Touch Command

If you want to create a single file in Linux with the help of This command, then first you have to type touch command, then you have to give single space, write the name of the file with which you want to create

touch file_name
touch command in linux

To check the file created by the touch command, use the ls command, to check all the files created in the current directory use ll or -l switch

Create multiple files with Touch command

In Linux/Unix sometimes system administrator and programmer need to create more than one empty file at the same time, then you can use this command. You can run the ls command in terminal to check whether simultaneously multiple files have been created OR not .

touch File1 File2 File3
create multiple file in touch command

If you want to create multiple files at once with the this command, then for this you have to give the starting and ending number of the file in curly braces.

touch <filename{<start>..<finish>}
create multiple files with touch command

Let us understand the multiple function of touch command with another example, if you want to create more than one file and want to add number or character while creating the file then you can use this command

create more then one file in touch command

touch Options

There are some other options of Linux touch command which you can use according to your need. You can see some examples below , But it depends on the version of Linux,

OptionsyntaxExplanation
touch -atouch -a <filename>  Used to change the access and modification time of a file
touch -ctouch -c <filename>  This option can be used to check whether the file is already created or not. If the file is already created, it will give an error message. If the file is not created then the file will be create
touch -dtouch -d <filename>  To update the time of one file with reference to another file, this option is used in touch command.
touch -mtouch -m <filename>  Use this option to change the last modification time of the file.
touch -ttouch -t <filename>  Use this option to create a file in a specific time.
touch command options

also visit this blog Simiservice.com

Rate this post