The touch command is built upon the utime()/utimes() system calls. So look up those system calls for your OS to see why they might fail. My copy of AIX 5.3 docs says:
Hmmm, I hope that is an error in documentation or at least the docs are unclear. It is supposed to be like this...
The effective uid must own the file and have write permission to the file or the effective uid must be root. If the Times parameter is null, we are just seeing if we could change the times if we wanted to... but we will not actually change anything if we have permission. If it fails, you get EPERM or EACCES depending on whether or not you were trying to change anything.
But if you are not root, you must own the file. This is required by Posix.
I would like to "touch" all of the files in all of my directories.
Instead of typing touch *.* in each directory, how would have unix touch all files in all of my directories?
Thanks!! (1 Reply)
hello everyone i am new to this forum and was wondering if you all could help me out.... i am looking for a touch command that can touch directories as well as files that does not involve sygwin... any and all help would be appreiciated :D (3 Replies)
Hi,
This might be the stupidest question ever but here it goes, i need to create a file with the name Hello! It's $s It using the touch command
but whenever i use
touch 'Hello! It's $s'
i get s is undefined
touch Hello! It's $s
i get ' unmatched
Please help ^_^ (6 Replies)
Hi All,
I have requirement to give permission to empty file. I do it in two steps.
But is it possible using touch command with some option for providing permission for a file.
Regards,
gehlnar (3 Replies)
I have a folder with many subdirectories and i need to set the modified date to today for everything in it. Please help, thanks!
I tried something i found online, find . -print0 | xargs -r0 touch
but I got the error: xargs: illegal option -- r (5 Replies)
Hi all
I changed some of my files in my hoem directory to old dates using the touch command like this
touch -t 200805101024 file name
but after using this command the date changed properly but it displays like below
-rwxr--r-- 1 fincntrg fingrp 193619 May 10 2008 vi.pdf
I... (3 Replies)
Hello,
I am trying to use touch command to create 1200 .txt files. I am using this, but it is not working.
touch `seq 1 1200`.txt
Regards,
Siddhesh.K (5 Replies)
Hello fellow Unix geeks,
I have been given a very urgent assignment in my office on writing a particular Shell script but I'm very much new to it.I would appreciate any help from you on solving this problem--which might seem very trivial to you.
The Unix flavour is a Sun Solaris one..(not... (6 Replies)
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
LEARN ABOUT OPENSOLARIS
utime
utime(2) System Calls utime(2)NAME
utime - set file access and modification times
SYNOPSIS
#include <sys/types.h>
#include <utime.h>
int utime(const char *path, const struct utimbuf *times);
DESCRIPTION
The utime() function sets the access and modification times of the file pointed to by path, and causes the time of the last file status
change (st_ctime) to be updated.
If times is NULL, the access and modification times of the file are set to the current time. A process must be the owner of the file or
have write permission to use utime() in this manner.
If times is not NULL, times is interpreted as a pointer to a utimbuf structure (defined in <utime.h>) and the access and modification times
are set to the values contained in the designated structure. Only the owner of the file or a process that has the {PRIV_FILE_OWNER} privi-
lege asserted in its effective set can use utime() in this manner.
The utimbuf structure contains the following members:
time_t actime; /* access time */
time_t modtime; /* modification time */
The times contained in the members of the utimbuf structure are measured in seconds since 00:00:00 UTC, January 1, 1970.
RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.
ERRORS
The utime() function will fail if:
EACCES Search permission is denied by a component of the path prefix.
EACCES The process does not have appropriate privileges and is not the owner of the file, write permission is denied for the file,
and times is NULL.
EFAULT The path argument points to an illegal address.
EINTR A signal was caught during the execution of the utime() function.
EIO An I/O error occurred while reading from or writing to the file system.
ELOOP Too many symbolic links were encountered in translating path.
ENAMETOOLONG The length of the path argument exceeds PATH_MAX, or the length of a path component exceeds NAME_MAX while _POSIX_NO_TRUNC
is in effect.
ENOENT The named file does not exist or is a null pathname.
ENOLINK The path argument points to a remote machine and the link to that machine is no longer active.
ENOTDIR A component of the path prefix is not a directory.
EPERM The effective user of the calling process is not the owner of the file, {PRIV_FILE_OWNER} is not asserted in the effective
set of the calling process, and times is not NULL.
EROFS The file system containing the file is mounted read-only.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |Async-Signal-Safe |
+-----------------------------+-----------------------------+
SEE ALSO stat(2), utimes(2), attributes(5), privileges(5), standards(5)SunOS 5.11 19 Apr 2004 utime(2)