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 MOJAVE
futimes
UTIMES(2) BSD System Calls Manual UTIMES(2)NAME
futimes, utimes -- set file access and modification times
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <sys/time.h>
int
futimes(int fildes, const struct timeval times[2]);
int
utimes(const char *path, const struct timeval times[2]);
DESCRIPTION
The access and modification times of the file named by path or referenced by fildes are changed as specified by the argument times.
If times is NULL, the access and modification times are set to the current time. The caller must be the owner of the file, have permission
to write the file, or be the super-user.
If times is non-NULL, it is assumed to point to an array of two timeval structures. The access time is set to the value of the first ele-
ment, and the modification time is set to the value of the second element. The caller must be the owner of the file or be the super-user.
In either case, the inode-change-time of the file is set to the current time.
RETURN VALUES
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the
error.
ERRORS
The utimes() system call will fail if:
[EACCES] Search permission is denied for a component of the path prefix; or the times argument is NULL and the effective user ID of
the process does not match the owner of the file, and is not the super-user, and write access is denied.
[EFAULT] path or times points outside the process's allocated address space.
[EIO] An I/O error occurs while reading or writing the affected inode.
[ELOOP] Too many symbolic links are encountered in translating the pathname. This is taken to be indicative of a looping symbolic
link.
[ENAMETOOLONG] A component of a pathname exceeds NAME_MAX characters, or an entire path name exceeded PATH_MAX characters.
[ENOENT] The named file does not exist.
[ENOTDIR] A component of the path prefix is not a directory.
[EPERM] The times argument is not NULL and the calling process's effective user ID does not match the owner of the file and is not
the super-user.
[EROFS] The file system containing the file is mounted read-only.
The futimes() system call will fail if:
[EBADF] fildes does not refer to a valid descriptor.
All of the functions will fail if:
[EACCES] The times argument is NULL and the effective user ID of the process does not match the owner of the file, and is not the
super-user, and write access is denied.
[EFAULT] times points outside the process's allocated address space.
[EIO] An I/O error occurred while reading or writing the affected inode.
[EPERM] The times argument is not NULL and the calling process's effective user ID does not match the owner of the file and is not
the super-user.
[EROFS] The file system containing the file is mounted read-only.
SEE ALSO stat(2), utime(3)HISTORY
The utimes() function call appeared in 4.2BSD. The futimes() function call first appeared in FreeBSD 3.0.
BSD June 4, 1993 BSD