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
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
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>}
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
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,
Option | syntax | Explanation |
---|---|---|
touch -a | touch -a <filename> | Used to change the access and modification time of a file |
touch -c | touch -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 -d | touch -d <filename> | To update the time of one file with reference to another file, this option is used in touch command. |
touch -m | touch -m <filename> | Use this option to change the last modification time of the file. |
touch -t | touch -t <filename> | Use this option to create a file in a specific time. |
also visit this blog Simiservice.com
- What Is a Content Delivery Network (CDN) and How Does It Work? - 4 November 2024
- What is Microsoft Windows? Features, Functions, And Benefits - 3 November 2024
- What Is Wireless Networking? Types, Benefits & How It Works - 3 November 2024