Sponsored Content
Full Discussion: file date format
Top Forums UNIX for Advanced & Expert Users file date format Post 302072199 by buffoonix on Friday 28th of April 2006 06:16:36 PM
Old 04-28-2006
You need to stat the file yourself by the namesake syscall.
Either write a small C wrapper program or you could write a Perl wrapper which is more effortless

e.g.
Code:
$ perl -MPOSIX=strftime -le 'print strftime("%Y%m%d", localtime((stat shift)[9]))' /etc/passwd
20060414
$ ls -l /etc/passwd
-rw-r--r--  1 root root 2224 Apr 14 18:25 /etc/passwd

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

2. Shell Programming and Scripting

Format a date in a csv file

So I have a csv file where the 3rd field is a date string in the format yyyy-mm-dd. I need to change it to mm/dd/yyyy. So each line in the csv file looks like: StringData,StringData,2009-02-17,12.345,StringData StringData,StringData,2009-02-16,65.789,StringData Any idea how I can keep... (5 Replies)
Discussion started by: rpiller
5 Replies

3. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

4. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

5. Shell Programming and Scripting

How to change date format in file

Hello! I have a textfile that look like this: "83d1:46:2b";"20091008190000";"Rögle BK - Skellefteå";"Swedish" "d4c:46:21";"20091008190000";"Södertälje - Brynäs";"Swedish" "d4b:46:2";"20091008190000";"HV 71 - Färjestad";"Swedish" "838:46:b";"20091010160000";"Skellefteå - HV 71";"Swedish"... (2 Replies)
Discussion started by: condmaster
2 Replies

6. Shell Programming and Scripting

finding date numeral from file and check the validity of date format

hi there I have file names in different format as below triss_20111117_fxcb.csv triss_fxcb_20111117.csv xpnl_hypo_reu_miplvdone_11172011.csv xpnl_hypo_reu_miplvdone_11-17-2011.csv xpnl_hypo_reu_miplvdone_20111117.csv xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Discussion started by: manas_ranjan
10 Replies

7. Shell Programming and Scripting

File date format how to change

Hi All, Below are the unix files taken by the help of ls -lrt -rw-r--r-- 1 kbehera Domain Users 293 Jul 27 13:33 sand.txt -rw-r--r-- 1 kbehera Domain Users 4 Jul 27 13:37 sand1.txt -rw-r--r-- 1 kbehera Domain Users 293 Jul 27 15:30 new_sand.txt -rw-r--r-- 1 kbehera Domain Users 0 Jul 27... (2 Replies)
Discussion started by: krupasindhu18
2 Replies

8. UNIX for Dummies Questions & Answers

Rename all Files in a UNIX Directory from one date format to another date format

Hi Unix Gurus, I would like to rename several files in a Unix Directory . The filenames can have more than 1 underscore ( _ ) and the last underscore is always followed by a date in the format mmddyyyy. The Extension of the files can be .txt or .pdf or .xls etc and is case insensitive ie... (1 Reply)
Discussion started by: pchegoor
1 Replies

9. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

10. UNIX for Beginners Questions & Answers

Change date format in a file.

Hi all, I have a file as below, i would like the change the format of the time from "11/7/2019 20:12" to "2019-07-11 20:12:00" in the last coloumn. any awk solution on this. Input: 2,0,695016,1961612,497212,5800804,0,0,161,33,7605,12226,23,10,66,0,0,34,11/7/2019 20:10... (4 Replies)
Discussion started by: Raghuram717
4 Replies
shift(1)							   User Commands							  shift(1)

NAME
shift - shell built-in function to traverse either a shell's argument list or a list of field-separated words SYNOPSIS
sh shift [n] csh shift [variable] ksh * shift [n] DESCRIPTION
sh The positional parameters from $n+1 ... are renamed $1 ... . If n is not given, it is assumed to be 1. csh The components of argv, or variable, if supplied, are shifted to the left, discarding the first component. It is an error for the variable not to be set or to have a null value. ksh The positional parameters from $n+1 $n+1 ... are renamed $1 ..., default n is 1. The parameter n can be any arithmetic expression that evaluates to a non-negative number less than or equal to $#. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 shift(1)
All times are GMT -4. The time now is 02:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy