touch Command 8 Best Practical Examples Linux / Unix

As most of the basic user know that touch command is used to create empty files. We can create one or more files using single touch command. In this Article we are going to discuss not only the touch options to create files but modifying file access Date, Modified Date and time STAMP as well. Touch Command Linux & Touch Command Unix.

Touch Command 8 Best Practical Examples

Command Syntax: touch FileName(s)

# touch arkit

Above is the touch command example which can create empty file called arkit. To list created file use ls command

Create Multiple Files Using touch

# touch file1 file2 file3

Don’t want to provide multiple file name when i am creating multiple files using touch, just provide wildcard so that it will create similar name files more than 100 or 1000 whatever number you provide

# touch Text{1..10}.txt
touch command Linux examples

touch examples

File’s can also be created with specific date using touch –date Option. Which is most useful one specific requirements fulfill

# touch --date="Sun,  29  May  2017  16:21:42  -0800" Testing123

Testing123 file created with Year=2017, Month = May, Date = 29 and Day = Sunday.

Modify File Time Stamp Using touch Command

Here we can use -r Or -t option to change file time stamp. -r is used to take the reference from file and assign to destination file. -t is used to change time stamp by provide date-time in specific format

# touch -t 1705292005 oldfile

sets the modification time of oldfile to 20:05 on May 29, 2017.

# touch -r anaconda-ks.cfg touch/testing

sets the modification time of touch/testing to that of anaconda-ks.cfg file

Change Access time stamp using touch

# touch -a touchcommand10.txt

Above practical example will change file access time stamp from old to current

touch access time change

touch access time change

Modification time can also be changed using touch let’s see below example option is -m

# touch -m touchcommand10.txt

That’s it about touch command 8 practical examples. I hope you enjoyed reading this article, please do comment your feedback on the same

Related Articles

How you Know You’re doing Right ps Command

Paste Command with 10 Practical Examples

Download Linux Commands cheat Sheet

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *