| 
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 |  |  | --- | 
					
						
							|  |  |  | title: Bash touch | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Bash command: touch
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | **Change timestamps of files.** | 
					
						
							| 
									
										
										
										
											2018-10-28 10:03:32 -05:00
										 |  |  | **Quickly create new files.** | 
					
						
							| 
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-16 20:12:24 -08:00
										 |  |  | ### Usage
 | 
					
						
							| 
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 |  |  | ``` | 
					
						
							|  |  |  | touch [options] filename | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-28 10:03:32 -05:00
										 |  |  | Creates empty file if filename does not exist or modifies timestamps of existing files to current time. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This command can create multiple empty files in one line of code. | 
					
						
							| 
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | Commonly used options: | 
					
						
							|  |  |  | - `-t` change timestamp to specific date ((YYYYMMDDHHMM.SS)) instead of current time. | 
					
						
							|  |  |  | - `-r` use timestamp from first file to second file. | 
					
						
							| 
									
										
										
										
											2018-10-24 05:06:51 +02:00
										 |  |  | - `-a` In case you want to only change the access time, use the -a command line option. | 
					
						
							|  |  |  | - `-m` Similarly, if the requirement is to only change the modification time, use the -m command line option. | 
					
						
							| 
									
										
										
										
											2019-01-16 20:12:24 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Example
 | 
					
						
							| 
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 |  |  | ``` | 
					
						
							|  |  |  | touch -t YYYYMMDDHHMM.SS filename | 
					
						
							|  |  |  | touch -r file1 file2 | 
					
						
							| 
									
										
										
										
											2018-10-24 05:06:51 +02:00
										 |  |  | touch -am file3 | 
					
						
							| 
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### More Information:
 | 
					
						
							|  |  |  | * [Man pages](http://man7.org/linux/man-pages/man1/touch.1.html) | 
					
						
							| 
									
										
										
										
											2018-10-28 10:03:32 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | * [Examples and options to use with the touch command](https://ss64.com/bash/touch.html) |