Hello. I am writing a script to do some copying of files. I feel confident that I can do that part, but before I even start doing the actual copies, it compares the last modified dates of two files.. I know this seems a very basic question that I would be able to find in the MAN pages for 'stat', but it says to use argument 'amcB' to get the mod date... what?

Oh, and I tried a raw 'stat' (with no args) to see what the output looked like, but it is just a list of numbers...

$ cd ~/
$ stat Documents/
234881026 195617 drwx------ 7 username staff 0 238 "Sep 19 21:43:13 2011" "Sep  8 11:18:35 2011" "Sep  8 11:18:35 2011" "Jun 18 21:01:24 2009" 4096 0 0 Documents/

I either need someone to tell me a place to find the format of those numbers, (what each of them is).. then I could just have the computer extract the mod date/time.. which I think is a float in seconds... OR if there is a way to just flat out do this, I would definitely settle for that explanation.. thanks.

What system is this? Also, can you quote more context from the man page?
Because normally to get a modtime one would call

stat '%Y' filename
$ stat '%Y' Documents
234881026 195617 drwx------ 7 username staff 0 238 "Sep 19 21:43:13 2011" "Sep  8 11:18:35 2011" "Sep  8 11:18:35 2011" "Jun 18 21:01:24 2009" 4096 0 0 Documents/

I can see that there are two date/time Strings in the stats, but I do not know which is which... which one is the mod time?

Sorry, a typo there. Missed -c:

$ stat -c '%Y' .
1317010317
$

The value is a modtime in seconds since epoch.
Still, which system are you using, and what exactly the manpage says?

oh ok, thanks.. I'm using a mac.. and that was basically what my question boiled down to.. which number is/how do I get the mod time alone.. and i can see now by specifying the c arg and formatting %Y. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.