Converting the File Creation Date to a new format


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Converting the File Creation Date to a new format
# 1  
Old 06-12-2002
Question Converting the File Creation Date to a new format

I need to capture a file's creation/modification date and time and convert this to a different format, whilst I can easily get the existing format from a ls -l | awk ' { print $......}' or a cut command I do not know how to convert it to a desired format?

I should add that at present the ls -l on the system I am using gives a date format of:-


ls -l |awk '{print $7" "$6" "$8" "} '

30 May 22:44
17 May 10:06

Whilst I need the format to be YYYY.MM.DD

eg 2002.05.10

any ideas much appreciated

Last edited by barney_clough; 06-12-2002 at 09:18 AM..
# 2  
Old 06-12-2002
Hi there.

You need to convert it to what kind of format? DD-MM-YYYY? If you wanto to switch the position of 'ls -l' creation/modification date, you can use the same command that you used, exchanging the posistion of the fields that awk gets. EX.

ls -l |awk '{print $7" "$6" "$8" "} '

to display it in DD-MM-YYYY(TIME)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - problems by converting date-format

Hi i try to change the date-format from DD/MM/YYYY into MM/DD/YY. Input-Data: ... 31/12/2013,23:40,198.00,6.20,2,2,2,1,11580.0,222 31/12/2013,23:50,209.00,7.30,2,2,3,0,4380.0 01/01/2014,00:00,205.90,8.30,2,2,3,1,9360.0,223 ... Output-Data should be: ...... (7 Replies)
Discussion started by: IMPe
7 Replies

2. Shell Programming and Scripting

Converting the date format

Hi All, I am new to this forum. Could anyone help me to resolve the following issue. Input of the flat file contains several lines of text for example find below: 5022090,2,4,7154,88,,,,,4/1/2011 0:00,Z,L,2 5022090,3,1,6648,88,,,,,4/1/2011 0:00,Z,,1 5022090,4,1,6648,88,,,,,4/1/2011... (6 Replies)
Discussion started by: av_sagar
6 Replies

3. UNIX for Advanced & Expert Users

Converting the date format in a flat file

Hi All, I am new to this forum, could any one help me out in resolving the below issue. Input of the flat file contains several lines of text for example find below: 5022090,2,4,7154,88,,,,,4/1/2011 0:00,Z,L,2 5022090,3,1,6648,88,,,,,4/1/2011 0:00,Z,,1... (0 Replies)
Discussion started by: av_sagar
0 Replies

4. Shell Programming and Scripting

converting Date format

Dear Friends, We have date in output as MM/DD/YYYY format and I want to convert it in DD/MM/YYYY format. e.g. 12/31/2010 to 31/12/2010 We have checked forum for the solution but we are not getting matching query. Please guide us Thanks Anushree. (6 Replies)
Discussion started by: anushree.a
6 Replies

5. Shell Programming and Scripting

Converting windows format file to unix format using script

Hi, I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix. My requirement here is that i want to do it automatically using a... (5 Replies)
Discussion started by: sarbjit
5 Replies

6. Shell Programming and Scripting

Converting file format

My input file is Pipe delimited with 10 fields, I am trying to create a tab delimited output file with 6 fields from the provided input file. Below is sample data Input file abc||2|PIN|num||||www.123.com|abc@123.com| bcd||2|PIN|num|||||abc@123.com|... (3 Replies)
Discussion started by: pasupuleti81
3 Replies

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

8. Shell Programming and Scripting

converting date format

Hi Please anyone to help to write script to convert date to 'yyyy-mm-dd'(If column is date convert) because my file has large and lot of date colums. If file is small ,using awk command to achive. cat file1|awk 'BEGIN {FS=OFS='|'}... (7 Replies)
Discussion started by: mohan705
7 Replies

9. UNIX for Dummies Questions & Answers

Changing Creation Date to a Prespecified Date of a File In Unix

Dear Expert, Is there a command to do that in Unix? In such a way that we don't need to actually "write" or modified the content. -- monkfan (4 Replies)
Discussion started by: monkfan
4 Replies
Login or Register to Ask a Question