Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How do I get the last modified date of a file? Post 6073 by Optimus_P on Wednesday 29th of August 2001 12:46:07 PM
Old 08-29-2001
use the ls command w/ the -latr swithchs will give the list of files from oldest to newst modified.

Code:
#man ls

-t        Sort by time stamp (latest first)  instead  of  by
               name.  The  default is the last modification time.
               (See -u and -c.)

-u        Use time of last access instead of last  modifica-
               tion  for sorting (with the -t option) or printing
               (with the -l option).

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to retrieve original contents of a modified file (modified using vi)

Made changes to a file using vi editor and saved those changes now realised that the changes are not required How can I get the previous version of the file.i.e the one which was there on which I had made changes (3 Replies)
Discussion started by: novice100
3 Replies

2. Shell Programming and Scripting

Finding modified File List after the chosen date in Korne Shell...

I am trying to write a Korne Shell asking the user for a date and a directory and then search recursively in this directory the list of files modified after the date chosen. But I am not getting good results when I Test it... #!/usr/bin/ksh echo "Enter a date (YYYYMMDD) " read date touch -t... (2 Replies)
Discussion started by: marconi
2 Replies

3. UNIX for Advanced & Expert Users

Finding the modified date time of a file

Hi, I am new bie to Unix. Might be a simple question I am asking. I want to find the last modified time of a file and find the difference between the currrent time and the last modified time. Appreciate, if someone can throw some light on what commands can be used. Cheers, James (2 Replies)
Discussion started by: JamesJoe
2 Replies

4. Shell Programming and Scripting

Test if a file has a last modified date of within the last 24 hours

Hi there Im trying to find a way to test whether the last modified time is older than 1 day or not so #!/bin/bash if ; then $TOUCHED = "recently" else $TOUCHED = "not so recently" fi ive seen loads of posts where people are using find and the -mtime property but i... (2 Replies)
Discussion started by: rethink
2 Replies

5. Shell Programming and Scripting

current date modified file

Hi , In my directory , i have many days file but i want to see all those which are of todays date. i tried this but it gives all the files mtime -0 |ls -ltr I tried the below option as well. 19635 find -iname "*.LOG" -mtime 19636 ls -ltr *.LOG -mtime -1 19637 ls -ltr *.LOG... (7 Replies)
Discussion started by: guddu_12
7 Replies

6. Shell Programming and Scripting

Find file by filename or with newest modified date

Hi, I have a directory that has numerous files in it, and there is two which are named "filerec_ddmmyyHH24MMSS" by the time they are created so "filerec_010615012250" was created at 01:22:50 on 1st June 2015. I need to find the most recently created of those 2 files and get the contents of... (4 Replies)
Discussion started by: finn
4 Replies

7. Shell Programming and Scripting

Script to copy creation date over top of modified date?

Can someone draw up a script that for every file, folder and subfolder and files that will copy the creation date over top of the modified date?? I know how to touch every file recursively, but no idea how to read a files creation date then use that to touch the modification date of that file,... (3 Replies)
Discussion started by: toysareforboys
3 Replies

8. AIX

How do I display a file's last modified date?

I'm using a script that I need to get a file's "last modified date" in a format like 01:51:14 PM. We are running on AIX 6.1.0.0. I can't seem to find the right command parameters. Help! (4 Replies)
Discussion started by: mattadams1983
4 Replies

9. OS X (Apple)

Arrange file by modified date

Hi, Am performing a find based on filename and result can contain multiple files being found Let's say my find command is find /Archive -f -name 12345.pdf and result of find command is /Archive/Folder A/12345.pdf /Archive/Folder B/12345.pdf please note white space in folder names I... (2 Replies)
Discussion started by: gigagigosu
2 Replies

10. UNIX for Beginners Questions & Answers

Need help with listing file name and modified date on a huge directory

hi, We have a huge directory that ha 5.1 Million files in it. We are trying to get the file name and modified timestamp of the most recent 3 years from this huge directory for a migration project. However, the ls command (background process) to list the file names and timestamp is running for... (2 Replies)
Discussion started by: subbu
2 Replies
ls(1)							      General Commands Manual							     ls(1)

Name
       ls - list and generate statistics for files

Syntax
       ls [ options ] name ...

Description
       For each directory argument, lists the contents of the directory.  For each file argument, repeats the file name and gives any other infor-
       mation you request with the options available.  By default, the list is sorted alphabetically.  When no	argument  is  given,  the  current
       directory  is  listed.	When several arguments are given, files are listed first, followed by directories and the files within each direc-
       tory.  Options are listed below.

Options
       -1   Displays one entry per line.  This is the default when output is not to a terminal.

       -a   Displays all entries including those beginning with a period (.).

       -C   Forces multicolumn output for pipe or filter.  This is the default when the output is to a terminal.

       -c   Uses time of last file status change (ctime), reflecting file creation, mode, etc., for sorting (with the -t option) or printing (with
	    the -l option) rather than the time of file modification or access. See also the -t and -u options.

       -d   Displays names of directories only, not contents.  Use this option with -l to get the status of a directory.

       -F   Marks  directories	with  trailing	slash (/), sockets with a trailing equal sign (=), symbolic links with a trailing at sign (@), and
	    executable files with a trailing asterisk (*).

       -f   Displays names in the order they exist in directory.  For further information, see Entries	beginning  with  a  period  (.)  are  also
	    listed.  This option overrides the -l, -t, -s, and -r options.

       -g   Displays assigned group ID (used with -l only).  Default is assigned owner ID.

       -i   Displays the i-number for each file in the first column of the report.

       -L   Lists  the	information,  if  the file is a symbolic link, for the file or directory the link references rather than that for the link
	    itself.

       -l   Lists the mode, number of links, owner, size in bytes, and time of last modification (mtime) for each file.  If the file is a  special
	    file, the size field contains the major and minor device numbers instead of the size.  If the file is a symbolic link, the pathname of
	    the linked-to file is printed, preceded by ``->''.

	    The mode field consists of 11 characters.  The first character indicates the type of entry:

	    d if the entry is a directory
	    b if the entry is a block-type special file
	    c if the entry is a character-type special file
	    l if the entry is a symbolic link
	    s if the entry is a socket
	    - if the entry is a plain file

	    The next 9 characters are interpreted as three sets of three characters each.  The first set of three characters refers to file-access
	    permissions  for  the user; the next set, for the user-group; and the last set, for all others.  The permissions are indicated as fol-
	    lows:

	    r if the file is readable
	    w if the file is writable
	    x if the file is executable
	    - if the indicated permission is not granted.

	    The group-execute permission character is given as s if the file has the set-group-id bit set; likewise, the  user-execute	permission
	    character is given as s if the file has the set-user-id bit set.

	    The last character of the mode (normally `x' or `-') is t if the 1000 bit of the mode is on.  See for the meaning of this mode.

       -q   Forces  the printing of nongraphic characters in file names as the question mark character (?).  This is the default when output is to
	    a terminal.

       -R   Recursively lists all subdirectories.

       -r   Sorts entries in reverse alphabetic or time order.

       -s   Displays the size in kilobytes of each file.  This is the first item listed in each entry.

       -t   Sorts by time modified (most recently modified first) instead of by name. See also the -c and -u options.

       -u   Uses the time of last access (atime) instead of last modification for sorting (with the -t option) or printing (with the -l option).

Restrictions
       The output device is assumed to be 80 columns wide.

       New line and tab are considered printing characters in file names.

       The option setting based on whether the output is a teletype is undesirable as "ls -s" is much different than "ls -s |lpr".  On	the  other
       hand, not doing this setting would make old shell scripts which used ls almost certain to fail.

Files
       Used to obtain user id's for ls -l

       Used to obtain group id's for ls -g

See Also
       stat(2)

																	     ls(1)
All times are GMT -4. The time now is 04:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy