How do I get at the modification date for a file as a variable for a script?

I realize this is basic and probably obvious, but I'm pulling my hair out. I'm guessing this is just some flag on the file command or somesuch, but I can't find it. Help me get unstuck please?

EDIT: I guess what I'm asking is once I've got the ls -l output for a file, what command do I use to take a specific part of that output (the modification date, or the group write permissions, for example) and somehow isolate or separate it so it can be compared to some other value?

  1. The problem statement, all variables and given/known data:

Get the current date from the UNIX system and print a statement as to whether the file was created today or not.

  1. Relevant commands, code, scripts, algorithms:

Wish I knew. All I really want to know is how to extract the modification date from a file in a form that can be plugged into an if/then statement. I can take it from there. I can pull the information up on screen with ls -l for all the files in a directory, I just can't figure out how to isolate it for one file so I can compare it to something else. The same goes for permissions, too.

  1. The attempts at a solution (include all code and scripts):

Numerous references to the textbook's index and some use of Google.

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

McHenry County College, Crystal Lake, IL, USA, Diaz, CIS 143

try this code to get the modification date

for ii in  `ls -l | awk -F" "  ' {print $6}'`
do
 echo $ii
done

anyway you can use find with option to get the files updated since a specific date

Or e.g.:

var=$(ls -l "$filename" |awk '{print $6}')

Group write permissions:

var=$(ls -l "$filename" |cut -c5-7)

If you need mutiple values

ls -l | 
while read permissions number_of_hard_links owner group size date time filename
do
   echo $date
   echo $permissions
done

Be advised that time output is not uniform and sometimes takes one column and sometimes two columns. Some 'ls'es have command line options to get around that

Thanks! I appreciate the helpful and speedy response. :slight_smile: