Visit Our UNIX and Linux User Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #64
Difficulty: Easy
HTTP uses UDP as the core transport protocol on the Internet.
True or False?
Linux & Unix Commands - Search Man Pages

touch(1) [bsd man page]

TOUCH(1)						      General Commands Manual							  TOUCH(1)

touch - update date last modified of a file SYNOPSIS
touch [ -c ] [ -f ] file ... DESCRIPTION
Touch attempts to set the modified date of each file. If a file exists, this is done by reading a character from the file and writing it back. If a file does not exist, an attempt will be made to create it unless the -c option is specified. The -f option will attempt to force the touch in spite of read and write permissions on a file. SEE ALSO
utimes(2) 7th Edition April 29, 1985 TOUCH(1)

Check Out this Related Man Page

TOUCH(1)						    BSD General Commands Manual 						  TOUCH(1)

touch -- change file access and modification times SYNOPSIS
touch [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ... DESCRIPTION
The touch utility sets the modification and access times of files to the current time of day. If the file doesn't exist, it is created with default permissions. The following options are available: -a Change the access time of the file. The modification time of the file is not changed unless the -m flag is also specified. -c Do not create the file if it does not exist. The touch utility does not treat this as an error. No error messages are displayed and the exit value is not affected. -f This flag has no effect; it is accepted for compatibility reasons. -h If file is a symbolic link, access and/or modification time of the link is changed. This option implies -c. -m Change the modification time of the file. The access time of the file is not changed unless the -a flag is also specified. -r Use the access and modifications times from the specified file instead of the current time of day. -t Change the access and modification times to the specified time. The argument should be in the form ``[[CC]YY]MMDDhhmm[.SS]'' where each pair of letters represents the following: CC The first two digits of the year (the century). YY The second two digits of the year. If ``YY'' is specified, but ``CC'' is not, a value for ``YY'' between 69 and 99 results in a ``CC'' value of 19. Otherwise, a ``CC'' value of 20 is used. MM The month of the year, from 1 to 12. DD The day of the month, from 1 to 31. hh The hour of the day, from 0 to 23. mm The minute of the hour, from 0 to 59. SS The second of the minute, from 0 to 61. If the ``CC'' and ``YY'' letter pairs are not specified, the values default to the current year. If the ``SS'' letter pair is not specified, the value defaults to 0. The touch utility exits 0 on success, and >0 if an error occurs. COMPATIBILITY
The obsolescent form of touch, where a time format is specified as the first argument, is supported. When no -r or -t option is specified, there are at least two arguments, and the first argument is a string of digits either eight or ten characters in length, the first argument is interpreted as a time specification of the form ``MMDDhhmm[YY]''. The ``MM'', ``DD'', ``hh'' and ``mm'' letter pairs are treated as their counterparts specified to the -t option. If the ``YY'' letter pair is in the range 69 to 99, the year is set to 1969 to 1999, otherwise, the year is set in the 21st century. SEE ALSO
utimes(2) STANDARDS
The touch utility is expected to be a superset of the IEEE Std 1003.2 (``POSIX.2'') specification. HISTORY
A touch utility appeared in Version 7 AT&T UNIX. BUGS
A symbolic link can't be a reference file of access and/or modification time. BSD
February 22, 2011 BSD

14 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

TFTP setup

ok, I configured inetd.conf so that the tftp string is not commented out, but I cannot get the process to start. I'm running Solaris 5.8 and need some help. Cabletron said that it's process is 3485, i tried to kill it, it's the wrong process. I started inetd again and still can't kill it. i... (15 Replies)
Discussion started by: veitcha
15 Replies

2. UNIX for Dummies Questions & Answers

file feed one line per argument

What tools can I use to accomplish this? I'm writing a shell script to analyze an inittab file. Here's a sample file: init:3:initdefault: ioin::sysinit:/sbin/ioinitrc >/dev/console 2>&1 tape::sysinit:/sbin/mtinit > /dev/console 2>&1 muxi::sysinit:/sbin/dasetup </dev/console >/dev/console... (10 Replies)
Discussion started by: jpprial
10 Replies

3. IP Networking

tcp/ip network

Hi, Can someone tell me how to set up a basic tcp/ip network on unix, so windows computers can ping it? Thnx, Edwin (10 Replies)
Discussion started by: edw1ns
10 Replies

4. UNIX for Dummies Questions & Answers

scripting help with touch and sed

Hello, I am trying to write a simple script to wake up every 300 seconds and look for a new file in a directory (e.g., "G102005"), remove the "G" from the file name, then print the new filename. Here's what I've got so far. I'm new at this so please forgive the errors or misuse of syntax. It... (14 Replies)
Discussion started by: alexkav
14 Replies

5. Shell Programming and Scripting

How to loop through directories to touch files

Hi, Please help me on this. Suppose i have the following directory structure. /app/data /app/data/eng /app/data/med /app/data/bsc each of the directories data,data/eng,data/med,data/bsc holds files with date extension like a.20081230 b.20081230 and so on I need a script to loop... (9 Replies)
Discussion started by: sussane
9 Replies

6. Shell Programming and Scripting

how to make a log.txt and add date and time when use ls,touch and find

Hey guy, how to make the log.txt file and record date and time when ls, touch and find command run? Thanks Boly (13 Replies)
Discussion started by: chenboly
13 Replies

7. UNIX for Dummies Questions & Answers

touch -t time, using different userid

Hi, I am reciveing files from a remote system on my linux box. These files are named based on time, which I can use to 'touch' the time . I can access/modify these files using my id. but when I tried touching time using my id I am getting error; touch -t 1001261234 1001261234_job2333... (15 Replies)
Discussion started by: rajivbravo
15 Replies

8. Shell Programming and Scripting

SCP and then touch .done file

All, I am looking to make a script and wanted to see if anyone could help out. The script will go through the directory, put a timestamp, transfer it and then create a touch $file.done script HEre is my initial idea, but I don't think it will work properly. Anyone able to help me refine it... (11 Replies)
Discussion started by: markdjones82
11 Replies

9. Shell Programming and Scripting

sh script for file received confirmation

I am new at scripting, (and this fourm- so hi guys!) and I was wondering is there something out there that I can use to do the following: I receive a file on an FTP server I would like a script to look at a specifc directory for a certain file and when it arrives it will send an email... (8 Replies)
Discussion started by: mamemlin
8 Replies

10. UNIX for Dummies Questions & Answers

[Solved] Touch 10% of the total files inside a folder

I'm trying to make this code below to work but I can't find the way to do the following: I want to make the script to touch only 10% of the total amount of files counted inside the given directory instead of all like it is now. I would greatly appreciate it if someone can give me a direction on... (9 Replies)
Discussion started by: regraphix
9 Replies

11. UNIX for Dummies Questions & Answers

Touch Challenge

I've been given a directory full of subdirectories full of logfiles of the same name: /logfiles/day1/file1/blockednodes.csv day1-14 file1-48 The above is the actual directory structure for 14 days worth of a logfile that is generated every 30 minutes. It's been done this way to preserve the... (15 Replies)
Discussion started by: Cludgie
15 Replies

12. Red Hat

Touch - changing date and time

Hi, I am facing a problem with the command - TOUCH on Linux. See the example below: File on Linux: rw-rw-r-- user1 user1 Jan 01 09:00 test.txt The file - test.txt was created by the user - user1. Now, I want to change the date and time, but using other user - user2 The user2... (12 Replies)
Discussion started by: brjohnsmith
12 Replies

13. Shell Programming and Scripting

Change date time stamp of existing file

I have a file hello.txt which was created today (today's date timestamp) I wish to change its date timestamp (access, modified, created) to 1 week old i.e one week from now. uname -a SunOS mymac 5.11 11.2 sun4v sparc sun4v Can you please suggest a easy way to do that ? (12 Replies)
Discussion started by: mohtashims
12 Replies

14. UNIX for Beginners Questions & Answers

Automate "touch" bash script not working.

#!/bin/bash -i SAVEIFS=$IFS IFS=$"\n\b" picc=$* if ; then echo $TDATE if ; then touch dummy touch -t "tdate" dummy touch -r "dummy" "$picc" else echo -e "No mod date value to apply. If there is one in your shell,\ninvoke \eStarted asking advice on this (on (9 Replies)
Discussion started by: iamwrong
9 Replies

Featured Tech Videos