stat(1) varies a great deal from one implementation to another (e.g., BSD stat has no -c option, some other systems don't even have the utility at all).
Your suggestion is GNU stat. If GNU stat is available, then the system has GNU chmod (they're both part of GNU coreutils), in which case the task is most easily accomplished with chmod --reference f1 f2
If portability is mandatory, then something unfortunately complex, like jayan_jay's suggestion, may be required.
I just downloaded a updating make file to build Ethereal to .dll file, but I don't know how to update the old make file with this new one. Please help.. thnx a lot. (1 Reply)
Hello,
i need some help/advice on how to solve a particular problem.
these are the users:
|name | group |
---------- ---------------
|boss | department1 |
|assistant | department1 |
|employee | department1 |
|spy | department2 |
this is the... (0 Replies)
I need to apply password protection to a xls file.I had looked at SpreadSheet::WriteExcel but problem being i dont want to write the contents of file again as the formatting the file would be a pain.
Is there way in which i write a entire file in one go , something like this
... (0 Replies)
Hi, I having an issue with file permission. To fix it I need to read the file's existing permission and re-apply the same permission to the file. This has to be done for every single file under a mount point. I'm novice in scripting. Help me with this in shell scripting.
# ls -l /dev/null... (10 Replies)
Hi Guys,
Can you tell me if unix permissions apply to sub dirs?
Dir is /home/ops/batch/files/all
/home is rwxrwxrwx
ops is rwxrwxrwx
batch is rwxr-wr-w
files is rwxrwxrwx
all is rwxrwxrwx
Having problems writing to all (does the userid nee to be the batch owner... (1 Reply)
Dear members..
I have a fixed width file. Requirement is as below:-
1. Scan each record from this fixed width file
2. Check for value under field no "6" equals to "ABC". If yes, then filter this record into the output file
Please suggest a unix command to achieve this, my guess awk might... (6 Replies)
HI there. My teacher asked us to write a code for this question
Write a Unix shell script named 'mode' that accepts two or more arguments, a file mode, a command and an optional list of parameters and performs the given command with the optional parameters on all files with that given mode. ... (1 Reply)
Write a Unix shell script named 'mode' that accepts two or more arguments, a file mode, a command and an optional list of parameters and performs the given command with the optional parameters on all files with that given mode.
For example, mode 644 ls -l should perform the command ls -l on all... (5 Replies)
I have a .csv file and I want to md5 hash the second column for each row in the file.
File is something like
data1,foobar1,123,345
data2,foobar2,456,9393
data3,foobar3,1002,10109
Output would be like
data1,6c81243028f8e455fa617dd5f0232ce1,123,345... (3 Replies)
In the bash below I am asking the user for a panel and reading that into bed. Then asking the user for a file and reading that into file1.Is the grep in bold the correct way to apply the selected panel to the file? I am getting a syntax error. Thank you :)
... (4 Replies)
Discussion started by: cmccabe
4 Replies
LEARN ABOUT PHP
stat
STAT(3) 1 STAT(3)stat - Gives information about a fileSYNOPSIS
array stat (string $filename)
DESCRIPTION
Gathers the statistics of the file named by $filename. If $filename is a symbolic link, statistics are from the file itself, not the sym-
link.
lstat(3) is identical to stat(3) except it would instead be based off the symlinks status.
PARAMETERS
o $filename
- Path to the file.
RETURN VALUES stat(3) and fstat(3) result format
+--------+--------------------------------------+---+
|Numeric | | |
| | | |
| | Associative | |
| | | |
| | Description | |
| | | |
+--------+--------------------------------------+---+
| 0 | | |
| | | |
| | dev | |
| | | |
| | device number | |
| | | |
| 1 | | |
| | | |
| | ino | |
| | | |
| | inode number * | |
| | | |
| 2 | | |
| | | |
| | mode | |
| | | |
| | inode protection mode | |
| | | |
| 3 | | |
| | | |
| | nlink | |
| | | |
| | number of links | |
| | | |
| 4 | | |
| | | |
| | uid | |
| | | |
| | userid of owner * | |
| | | |
| 5 | | |
| | | |
| | gid | |
| | | |
| | groupid of owner * | |
| | | |
| 6 | | |
| | | |
| | rdev | |
| | | |
| | device type, if inode device | |
| | | |
| 7 | | |
| | | |
| | size | |
| | | |
| | size in bytes | |
| | | |
| 8 | | |
| | | |
| | atime | |
| | | |
| | time of last access (Unix timestamp) | |
| | | |
| 9 | | |
| | | |
| | mtime | |
| | | |
| | time of last modification (Unix | |
| | timestamp) | |
| | | |
| 10 | | |
| | | |
| | ctime | |
| | | |
| | time of last inode change (Unix | |
| | timestamp) | |
| | | |
| 11 | | |
| | | |
| | blksize | |
| | | |
| | blocksize of filesystem IO ** | |
| | | |
| 12 | | |
| | | |
| | blocks | |
| | | |
| | number of 512-byte blocks allocated | |
| | ** | |
| | | |
+--------+--------------------------------------+---+
* On Windows this will always be 0.
** Only valid on systems supporting the st_blksize type - other systems (e.g. Windows) return -1.
In case of error, stat(3) returns FALSE.
Note
Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results
for files which are larger than 2GB.
ERRORS /EXCEPTIONS
Upon failure, an E_WARNING is emitted.
EXAMPLES
Example #1
stat(3) example
<?php
/* Get file stat */
$stat = stat('C:phpphp.exe');
/*
* Print file access time, this is the same
* as calling fileatime()
*/
echo 'Access time: ' . $stat['atime'];
/*
* Print file modification time, this is the
* same as calling filemtime()
*/
echo 'Modification time: ' . $stat['mtime'];
/* Print the device number */
echo 'Device number: ' . $stat['dev'];
?>
Example #2
Using stat(3) information together with touch(3)
<?php
/* Get file stat */
$stat = stat('C:phpphp.exe');
/* Did we failed to get stat information? */
if (!$stat) {
echo 'stat() call failed...';
} else {
/*
* We want the access time to be 1 week
* after the current access time.
*/
$atime = $stat['atime'] + 604800;
/* Touch the file */
if (!touch('some_file.txt', time(), $atime)) {
echo 'Failed to touch file...';
} else {
echo 'touch() returned success...';
}
}
?>
NOTES
Note
Note that time resolution may differ from one file system to another.
Note
The results of this function are cached. See clearstatcache(3) for more details.
Tip
As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to "Supported Protocols and Wrappers" to determine
which wrappers support stat(3) family of functionality.
SEE ALSO lstat(3), fstat(3), filemtime(3), filegroup(3).
PHP Documentation Group STAT(3)