You can use touch -m option to modify only modify time of a file in Linux.
Example:
Create a new empty file
1 2 |
## Create a new file touch myfile |
Get the file modify time
1 2 3 4 5 6 7 8 9 10 |
## Get the file modify time stat myfile ## returns ## File: myfile ## Size: 359 Blocks: 0 IO Block: 512 regular file ## Device: 2h/2d Inode: 116530640358219095 Links: 1 ## Access: (0644/-rw-r--r--) Uid: ( 1000/ debjeet) Gid: ( 1000/ debjeet) ## Access: 2022-02-02 18:26:06.407992300 +0530 ## Modify: 2022-02-02 18:26:06.407992300 +0530 ## Change: 2022-02-02 18:26:06.407992300 +0530 |
Update the file modify time only
1 2 |
## Update the file modify time only touch -m myfile ## changes file modify time |
Get the file modify time
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
## Get the file Modify time stat myfile ## returns ## File: myfile ## Size: 359 Blocks: 0 IO Block: 512 regular file ## Device: 2h/2d Inode: 116530640358219095 Links: 1 ## Access: (0644/-rw-r--r--) Uid: ( 1000/ debjeet) Gid: ( 1000/ debjeet) ## Access: 2022-02-02 18:24:29.580924200 +0530 ## Modify: 2022-02-02 18:28:59.445512400 +0530 ## Change: 2022-02-02 18:24:29.580924200 +0530 rm myfile |
Observe myfile Modify time has been changed.