Computing.Net > Forums > Unix > Unix script line - means what??

Unix script line - means what??

Reply to Message Icon

Original Message
Name: jrewen
Date: February 13, 2004 at 06:34:55 Pacific
Subject: Unix script line - means what??
OS: Win NT, Win XP, Linux
CPU/Ram: unknown
Comment:

Can someone help me decipher this? This is from an older Unix script, not sure exactly what it does:

...
find . $DATA -newer $DATESTAMP -exec stat -m {} \; > $FILELIST
...

$DATA is a list of files in a directory
$DATESTAMP is just a file with an old date
$FILELIST is just a file

from what I understand, this line will find all files (in the current directory) that are newer than $DATESTAMP's date.
for each file found, it will exec the "stat -m" command on it.
The results are written to $FILELIST.

this is where I'm confused, what actually gets written to $FILELIST? file names or when it was last modified? why would you want to exec "stat -m" on it? isn't "find ... - newer" enough to get the file names?

Thanks for any help


Report Offensive Message For Removal


Response Number 1
Name: fpmurphy
Date: February 13, 2004 at 07:37:16 Pacific
Subject: Unix script line - means what??
Reply: (edit)

What is being outputted to $FILELIST is
not just a list of file(name)s but also
additional information about those files.

stat(1) is a GNU utility. On your Linux
system type "info stat" to get full
information on what "stat -m" outputs.

-F


Report Offensive Follow Up For Removal

Response Number 2
Name: jrewen
Date: February 13, 2004 at 08:19:48 Pacific
Subject: Unix script line - means what??
Reply: (edit)

thanks for the input :)

but from what I understand, the command line "stat -m" would only return information regarding the modification of the file. At least that's what someone on this forum told me (thank you!), but I can't find that option detailed anywhere.

I'm 99% sure this isn't the stat struct that the Unix "man stat" returns.

RedHat 8.0 doesn't have that command line utility anymore, so I installed it via RPM - however, "-m" wasn't a possible option when I did an "info stat".

I think I understand that this script is supposed to write out the filenames, but that stat command confuses me. From the rest of the script, this file gets parsed up and each line instance of $FILELIST is called to be copied.

So maybe "stat -m" gets something else?


Report Offensive Follow Up For Removal

Response Number 3
Name: anonproxy
Date: February 15, 2004 at 10:54:15 Pacific
Subject: Unix script line - means what??
Reply: (edit)

"I'm 99% sure this isn't the stat struct that the Unix "man stat" returns."

Well, stat is a C library command, so its standard, especially among GNU components. I don't remember an -m flag though. stat used to be commonly interfaced similarly with lstat and fstat (which still exist for POSIX support), though now stat -l and stat -f perform the same functions on many Linux distributions.

For the information you want, call "stat -c --%y [filename]". %z would provide you the time of last change, as in file permissions, not data (%y).
GNU stat


Report Offensive Follow Up For Removal

Response Number 4
Name: Dlonra
Date: February 16, 2004 at 14:05:58 Pacific
Subject: Unix script line - means what??
Reply: (edit)

find . will recursively list all files and directories at . and below (as you can observe by running "find ."). Perhaps it is "find $DATA"?

you can gain a better understanding of find by "man find" - look for "-newer"

you can determine the the acceptable "stat" options by "man stat" and verify the options by running: stat --help or stat -?

in my case, stat -m file gives
stat: invalid option -- m


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Unix script line - means what??

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge