The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
retrieve value from a file satish@123 Shell Programming and Scripting 1 05-17-2008 04:40 AM
Retrieve data from a file tpltp Shell Programming and Scripting 2 03-28-2008 01:36 AM
how to retrieve a particular character from a file? singalla UNIX for Dummies Questions & Answers 1 02-27-2008 06:05 AM
How to retrieve a particular line from a file vinayap UNIX for Dummies Questions & Answers 2 07-11-2007 11:16 AM
Retrieve message from file mpang_ Shell Programming and Scripting 5 02-02-2007 05:38 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-08-2002
Registered User
 

Join Date: Aug 2002
Posts: 6
Stumble this Post!
Question retrieve timestamp associated with a file

Hi All,
I am involved in a Datawarehousing project where my data files(ASCII text) are loaded on a Unix directory. When I do a Ls -l in Unix prompt i get a file listing along with the timestamp when these files were created/put on the server. I need to retrieve the timestamp associated with each file. Is there any command that takes in the filename as an argument and returns the timestamp associated with it?? Or is there any other way to get the timestamp for each file..
Urgent help is sought!!
Thanks in advance..
Nilotpal.
Forum Sponsor
  #2 (permalink)  
Old 08-08-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,448
Stumble this Post!
"ls -l" is pretty much it. I assume that you know that "ls -l" can indeed take arguments? So:
ls -l filename
would seem to do what you want. If this is not the case, please tell us why.
  #3 (permalink)  
Old 08-08-2002
Registered User
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
Stumble this Post!
If you wanted to create a separate file that just had the filename in one column and the 'timestamp' in another...then you'd just use the ls -l command and cut the columns that you want (filename and date time....)

for example if all you files were data_xxx (where xxx differs but they all start with data_)

ls -l data_* | cut -c42-100 > my_file

Ideally with cut you'd use the -f for fields with the -d for delimiter, however the delimiter is space and the different columns have a different number of spaces as a delimiter. So you can just cut the characters 42-100 (note the 42 may differ so you need to find where the first character you want is..and 100 just goes way past the end to ensure you get all long filenames.)

There may be a way to use the -d and -f if you can specify the treat consecutive delimiters as one, however then you'd have to watch for filenames with spaces in them anyway.

Anyone know if there is a way with cut to treat consecutive delimiters as one?
__________________
Pete
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0