Sponsored Content
Full Discussion: Year of file creation
Top Forums UNIX for Dummies Questions & Answers Year of file creation Post 69954 by Perderabo on Friday 22nd of April 2005 12:34:35 PM
Old 04-22-2005
Try this script:
Code:
#! /usr/bin/ksh

typeset -Z2 d m
Jan=1 Feb=2 Mar=3 Apr=4 May=5 Jun=6 Jul=7 Aug=8 Sep=9 Oct=10 Nov=11 Dec=12
date "+%Y %m" | read year month

for i ; do
        line=$(ls -dl $i)
        line=${line##+([! ])+([ ])}
        line=${line##+([! ])+([ ])}
        line=${line##+([! ])+([ ])}
        line=${line##+([! ])+([ ])}
        line=${line##+([! ])+([ ])}
        set -A stamp $line
        d=${stamp[1]}
        eval m=\$${stamp[0]}
        y=${stamp[2]}
        ((${#y} != 4)) && ((y=year-(m>month)))
        echo $y $m $d $i
done
exit 0

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Year of file creation

Hello guys, I want to extract year of file creation. Is there a direct way to get that information. "ls -l" do give required information but if the file created is not older then 6 months it will not display the year. To get year one possible way will be do a math with date extracted by ls. ... (2 Replies)
Discussion started by: RishiPahuja
2 Replies

2. Shell Programming and Scripting

How do i get the year of the file

When i use, 'ls -ltr' I only see the month and day (timestamp) of the file. How do i see the year also. Thanks and Regards, Ram (1 Reply)
Discussion started by: ramky79
1 Replies

3. Shell Programming and Scripting

Move files based on year of creation

Hi All, I have a directory which has crores of files since from 2003 till now. I want to move only the 2003 files to another directory. Please help. Thanks (2 Replies)
Discussion started by: IHK
2 Replies

4. Shell Programming and Scripting

move file by year/mouth

Hello experts, I have a directory which the files inside have different date. Now I'd like to move them to folder year/mouth (2007/01 , 2007/02) Have any suggestion? thanks in advance for reading or anyposts. (3 Replies)
Discussion started by: mmm951
3 Replies

5. Shell Programming and Scripting

File created year

Hi I need to get the File creation date (MM,DD,YYYY) using ls -ltr am getting only Month and Day only, I need year also when the file is modified. Thanks (3 Replies)
Discussion started by: KiranKumarKarre
3 Replies

6. AIX

not showing the year of file

Hi I am facing strange issue in one direcotry it is not showing year of file, can you please suggest me wheather there is any limitation on year, on some other file though it is showing the dates. Regards, Manoj. (1 Reply)
Discussion started by: manoj.solaris
1 Replies

7. Shell Programming and Scripting

want to get last year and month from the file

Hi I have files like abc_cd_20110302_123423 abc_cd_ef_20110301_123423 abc_cd_ef_20110403_123423 abc_ef_20110401_123423 I want to extract the the year and month associated with each file. I tried logfileyearmonth=`echo $logfile | awk -F_'{print $NF}'` Any other way can I... (6 Replies)
Discussion started by: dgmm
6 Replies

8. UNIX for Dummies Questions & Answers

Sort file by day of year

Hello, It's a shame to not be able to do what I need, but I am sure you will : Here is what I have in my log file : New File: 95106 Jun 6 48 TAG__KSO__2012092_0.TAB New File: 95106 Mar 26 48 TAG__KSM__2012020_0.TAB New File: 95106 Mar 26 48 TAG__KSO__2012020_0.TAB New File: 95106 May... (3 Replies)
Discussion started by: Aswex
3 Replies

9. Shell Programming and Scripting

Shell script rm last 1 year file

HI I am using below script to remove only last year files and also need deleted files i want to keep in log file or history for future reference But it is giving wrong output please help or let me any other way for example 2016 if am using this command it is removing 2016 and 2017 files also... (2 Replies)
Discussion started by: Kalia
2 Replies

10. Shell Programming and Scripting

Display lines for a particular year in a file using grep

hi, I have a log file with data for more than 3 years, i want only the rows for the year 2017, say for example. My file has the data like this 08-OCT-2015 11:17:35 AAA, BBBB 08-OCT-2017 11:17:35 AAA,Bdfdfd,dfdfd,dfd 08-Nov-2017 11:17:35 AAA,Bdfdfd,dfdfd,deree i want the rows... (2 Replies)
Discussion started by: skoshekay
2 Replies
JDMONTHNAME(3)								 1							    JDMONTHNAME(3)

jdmonthname - Returns a month name

SYNOPSIS
string jdmonthname (int $julianday, int $mode) DESCRIPTION
Returns a string containing a month name. $mode tells this function which calendar to convert the Julian Day Count to, and what type of month names are to be returned. Calendar modes +-----+--------------------------------------+---+ |Mode | | | | | | | | | Meaning | | | | | | | | Values | | | | | | +-----+--------------------------------------+---+ | 0 | | | | | | | | | Gregorian - abbreviated | | | | | | | | Jan, Feb, Mar, Apr, May, Jun, Jul, | | | | Aug, Sep, Oct, Nov, Dec | | | | | | | 1 | | | | | | | | | Gregorian | | | | | | | | January, February, March, April, | | | | May, June, July, August, September, | | | | October, November, December | | | | | | | 2 | | | | | | | | | Julian - abbreviated | | | | | | | | Jan, Feb, Mar, Apr, May, Jun, Jul, | | | | Aug, Sep, Oct, Nov, Dec | | | | | | | 3 | | | | | | | | | Julian | | | | | | | | January, February, March, April, | | | | May, June, July, August, September, | | | | October, November, December | | | | | | | 4 | | | | | | | | | Jewish | | | | | | | | Tishri, Heshvan, Kislev, Tevet, She- | | | | vat, AdarI, AdarII, Nisan, Iyyar, | | | | Sivan, Tammuz, Av, Elul | | | | | | | 5 | | | | | | | | | French Republican | | | | | | | | Vendemiaire, Brumaire, Frimaire, | | | | Nivose, Pluviose, Ventose, Germinal, | | | | Floreal, Prairial, Messidor, Thermi- | | | | dor, Fructidor, Extra | | | | | | +-----+--------------------------------------+---+ PARAMETERS
o $jday - The Julian Day to operate on o $calendar - The calendar to take the month name from RETURN VALUES
The month name for the given Julian Day and $calendar. PHP Documentation Group JDMONTHNAME(3)
All times are GMT -4. The time now is 10:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy