2018-10-16 01:34:53 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								---
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								title: Bash touch
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								---
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-03 02:55:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# Bash command: touch
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-03 02:55:00 +01: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
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-03 02:55:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								## Usage
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								```
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								touch [options] filename
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								```
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								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-03-31 14:18:14 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- `-h` Is useful if you only want to change the symbolic link, instead of the referenced file.
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-16 20:12:24 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-03 02:55:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								## Examples
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								```bash
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								touch -t YYYYMMDDHHMM.SS filename
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-03 02:55:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								```
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								```bash
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								touch -r file1 file2
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-03 02:55:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								```
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								```bash
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-24 05:06:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								touch -am file3
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-16 01:34:53 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								```
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-03 02:55:00 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								## Additional Resources
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								- [Wikipedia](https://en.wikipedia.org/wiki/Touch_(Unix))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								- [Man pages](http://man7.org/linux/man-pages/man1/touch.1.html)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								- [Examples and options to use with the touch command](https://ss64.com/bash/touch.html)
							 |