how to know year create/modified files?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to know year create/modified files?
# 1  
Old 03-08-2007
how to know year create/modified files?

Dear all,
how to know created file time, include the year created/last modified?
if using
#ls -al only month date and time

Thank you.
# 2  
Old 03-08-2007
Quote:
$ ls -l
drwxrwxr-x 2 ww_tor irm 8192 Mar 2 09:09 monthly
-rw-rw-r-- 1 ww_tor irm 6802 Mar 7 04:56 p_JobStep
drwxrwxrwx 2 ww_tor irm 8192 Feb 6 02:39 reestabs
-rw-rw-rw- 1 ww_tor irm 38769 Nov 21 2005 sql_tor_p_68_tora38_mdl_7_cd
-rw-rw-rw- 1 ww_tor irm 1481 Nov 16 2005 sql_tora36_mdl_seris.dat
Here you can see for some of the files have the modified year. The files and folders which does not have year in above list are modified in the current year.

We cannot get the create time of files and folders.
# 3  
Old 03-08-2007
Quote:
Originally Posted by anbu23
Here you can see for some of the files have the modified year. The files and folders which does not have year in above list are modified in the current year.

We cannot get the create time of files and folders.
Ohh.. thanks. I check in linux it's different i think, but in FreeBSD give me the year information.
Linux :
#ls -l
-rw-r--r-- 1 root root 12685573 Nov 28 20:11 pwmjkt-200611282009.tgz

FreeBSD:
#ls -l
-rwxr--r-- 1 root wheel 644 Mar 17 2006 temo_backup.sh
# 4  
Old 03-08-2007
ls shows month day time for current files (6 months old or newer) and month day year for files older than 6 months.

For OpenBSD, you can use the ls -lT command to force the year.

Code:
grunty: ls -lT tz.tar.gz
-rw-r--r--  1 cschelin  users  15409631 Mar  1 18:50:22 2007 tz.tar.gz

In linux, you can use stat and just format the output to look like ls -lT in OpenBSD.

Code:
harpy: stat -c "%A %h %U %G %s %x" tz.tar.gz
-rw-r--r-- 1 cschelin cschelin 15409631 2007-03-01 19:16:34.000000000 -0700

It's not exact and just the stat command will return a lot of info:

Code:
harpy: stat tz.tar.gz
  File: `tz.tar.gz'
  Size: 15409631        Blocks: 30144      IO Block: 4096   regular file
Device: 901h/2305d      Inode: 32786       Links: 1
Access: (0644/-rw-r--r--)  Uid: (  501/cschelin)   Gid: (  501/cschelin)
Access: 2007-03-01 19:16:34.000000000 -0700
Modify: 2007-03-01 19:16:06.000000000 -0700
Change: 2007-03-01 19:16:06.000000000 -0700

Carl
# 5  
Old 03-08-2007
# 6  
Old 03-10-2007
alerting

how would i go about writing a script to alert myself when a file has been modified?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create file every year and log data to it

Hi there, Here is what I currently have and trying to come up with a logic to automatically append logs to a respective year file. The log files might get generated everyday or any other day, irrespective of which I want to copy all of the logs for that year into one file /tmp/<year>.log and then... (4 Replies)
Discussion started by: mbak
4 Replies

2. Shell Programming and Scripting

Merging two year files

Hi All, I need to merge few files as belowABC_NYFWFX.txt ABC_NYFQTFX.txt ABC_NYFMAFX.txt ABC_NYFAVFX.txt ABC_CYFWFX.txt ABC_CYFQTFX.txt ABC_CYFMAFX.txt ABC_CYFAVFX.txt ABC_CYBWFX.txt ABC_NYFWFX.txt & ABC_CYFWFX.txt should be merged into a single file and name should be... (3 Replies)
Discussion started by: Hypesslearner
3 Replies

3. Shell Programming and Scripting

Delete files using year

Hi All, how can i delete files from my Unix directory on the basis of year, i have files from 2001 to till 2014, but from their, i have to delete only 2013 file.Below is my file name rwxrwxrwx 1 guopt users 5169 Jul 12 00:30 grt592_20130712003000.SAP Thanks Kki (2 Replies)
Discussion started by: kki
2 Replies

4. UNIX for Dummies Questions & Answers

Copy files from one drive to another, keeping most recently modified files

Hi all, I am a bit of a beginner with shell scripting.. What I want to do is merge two drives, for example moving all data from X to Y. If a file in X doesn't exist in Y, it will be moved there. If a file in X also exists in Y, the most recently modified file will be moved to (or kept) in... (5 Replies)
Discussion started by: apocolapse
5 Replies

5. UNIX for Dummies Questions & Answers

Delete files by year

can someone provide a command to delete files by year? I have several files created last year 2009. Im trying to list first ls -lrt | grep '/2009/ {print $10}' by it returns no result. Pls advise (2 Replies)
Discussion started by: lhareigh890
2 Replies

6. Shell Programming and Scripting

Delete all files except last modified

Hello All, I need to delete all the files with a particular naming format at a fixed path except the latest 1. Please help. example: At path /tmp, I have 3 files viz: log1, log2 and log3. file log2 was the one that was modified most recently. So I need to find and delete log1 and log3... (2 Replies)
Discussion started by: mystition
2 Replies

7. UNIX for Dummies Questions & Answers

Create a list of files that were modified after a given date.

Hello Mates! I'm kinda new to unix and need to a solve a problem. Input: date Situation: With the given date I need to find a list of all such files starting from a given path that were modified after the given date. I experimented with the "find" with "-newer" but did not quite get it... (4 Replies)
Discussion started by: rkka
4 Replies

8. UNIX for Dummies Questions & Answers

Create Year directory, date subdirectory and archive the file

Hi, After checking all the UNIX threads, I am able to come up with a solution so far. I am working on a shell script where it moves the files to a certain directory. The conditions to check are 1) Check if the file exists in the current directory. 2) Check if the destination directory... (2 Replies)
Discussion started by: madhunk
2 Replies

9. 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

10. UNIX for Dummies Questions & Answers

How to find out the exact year in "Last modified time" using ls command

Hi, I understand that the ls command with "-l" option generates the "last modified time" of specific directory. However, some generated results displayed the "last modified time" with detail about the last modified year, for example: -rwxrwxrwx+ 1 smith dev 10876 May 16 2005 part2 ... (6 Replies)
Discussion started by: Dophlinne
6 Replies
Login or Register to Ask a Question