From FreeBSDwiki
Jump to: navigation, search

touch creates empty files, or updates the modification times on existing files if the user running touch has write permission to do so.

If you attempt to touch a file which already exists but you do not have write permissions to, or touch a new file in a directory in which you do not have write permissions, you will get a "Permission Denied" error. Otherwise it quietly succeeds and simply updates the mtime on the file / creates a new file with the specified name.

This is mostly useful for scripting operations in which you want to make sure a file exists to be opened before attempting to open it.

Personal tools