How do you get the last modification date of a file?
I'm trying to get the date output to be in the form yyyy-mm-dd (e.g. 2013-01-18)
When I run this on another file (by typing ./dateScript theFile.txt), I keep getting this message:
stat: illegal option -- c
What's wrong with my code here or how can I fix it?
What about the following instead? I was told that date -r does what I want, but I can't seem to get it to. Since I can't find much information on how to use the date command, I've put it off to the side unless someone else knows how I can get the last modified date from a file with the date command.
Any other simple suggestions to get the last modification date of a file so that I can append it to the end of said file would be great too. I've been trying to figure out some variation of this problem for a few hours now and at this point I have no new ideas and am completely stagnant, so any help is really appreciated.
Good morning,
I would like to find all files of a certain type and display their name as well as their modification date.
In order to do this, I would do the following:
find ./ -name *.csv | ????????
My question: what to put after the pipe instead of the question marks? Is there a basic... (5 Replies)
Hi
I'd like to know if is it possible to find files given a certain modification date (say, 01-05-2006, that's 1st of May 2006)
I can calculate the days backward:
find / -ctime 23
but I wish to search by exact modification day
Thanks (5 Replies)
Hi i have a ques in Shell scripting:
ques: accept a filename as a command line argument. Validate the input and display the last modification date for that file.
Help pls. (4 Replies)
hi. I need help my programing friends :p
I need to list all the files with a certain name (for example FileName) by last modification date but only the one with the last date. If there are two files with the same name and same modification date it should print the both.
For example in this set... (6 Replies)
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... (3 Replies)
Hi, I'm executing a script to check if a file has been modified on a shared folder.
I use this to start another script every time the file has been modified.
To do this I use the 'ls' command to get the last modification date of the file.
My problem is that the computer hosting the shared... (5 Replies)
How do i get the file modification date in number format (yyyy mm dd hh mm ss)
i used
ls -l pathname
but month is still in text "Aug" and year and time is not allways shown. time is show if it is in this year. and year is shown if it is before this year.
what do i need to get... (7 Replies)
Hello all !
I have a piece of code that generates the date of one day ago:
/usr/bin/gdate --date='1 day ago' | awk '{print $2 " " $3}'
Nov 3
I want the output to be in the form :
Nov 03
What other operation should I do for that ?
Help (2 Replies)
First, oh great Unix gurus, forgive if this is a stupid question.
Unix/Linux is not my main thing but I have been programming in C/C++ for many years. I will do my best to be specific.
I have a program in C/C++ that needs to modify the time of a given file. Currently I do this using utime()... (5 Replies)
SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise
Hi,
In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file.
How do I achieve this?
Regards,
Joe (2 Replies)
Discussion started by: roshanbi
2 Replies
LEARN ABOUT OSX
getfileinfo
GETFILEINFO(1) BSD General Commands Manual GETFILEINFO(1)NAME
/usr/bin/GetFileInfo -- get attributes of files and directories
SYNOPSIS
/usr/bin/GetFileInfo [-P -a[<attribute-letter>] | -c | -d | -m | -t] file ...
DESCRIPTION
/usr/bin/GetFileInfo is a tool to get the file attributes.
With no flags, GetFileInfo retrieves all information about the file. If exactly one option is provided, GetFileInfo retrieves and displays
just that information; supplying more than one is an error.
Flags:
-P Acts on a symlink file instead of the file the symlink resolves to.
-a[<attribute-letter>]
Gets a file's attribute bits where <attribute-letter> is one of the following:
a Alias file
b Has bundle
c Custom icon (allowed on folders)
d Located on the desktop (allowed on folders)
e Extension is hidden (allowed on folders)
i Inited - Finder is aware of this file and has given it a location in a window. (allowed on folders)
l Locked
m Shared (can run multiple times)
n File has no INIT resource
s System file (name locked)
t "Stationery Pad" file
v Invisible (allowed on folders)
z Busy (allowed on folders)
The value of a single attribute is printed as 0 for off or false, 1 for on or true. If no attribute letter is specified, the
value of all attributes is returned, with lowercase letters representing off or false, and uppercase representing on or true.
-t Gets the file type, a string of exactly four characters. If the type is not set, these will display as an empty pair of quo-
tation marks. Directories do not have types, so the type will be skipped if all information is being displayed; specifying -t
for a directory is an error.
-c Gets the file's creator, a string of four characters enclosed in quotation marks. If the creator is not set, these will dis-
play as an empty pair of quotation marks. Directories do not have creators, so the creator will be skipped if all information
is being displayed; specifying -c for a directory is an error.
-d Gets the creation date, a string of the form "mm/dd/yyyy hh:mm:ss" in 24-hour clock format.
-m Gets the modification date, a string of the form "mm/dd/yyyy hh:mm:ss" in 24-hour clock format.
RETURN VALUES
0 success
1 syntax error
2 any other error
SEE ALSO SetFile(1)EXAMPLES
The following command line gets and prints the creator for the "Late Breaking News" file:
/Developer/Tools/GetFileInfo -c "Late Breaking News"
This command line prints the modification date of "myFile":
/Developer/Tools/GetFileInfo -m myFile
Mac OS X September 27, 2005 Mac OS X