LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-18-2006, 06:49 PM   #1
_cih_
LQ Newbie
 
Registered: Nov 2006
Posts: 4

Rep: Reputation: 0
Retrieving file size, or its modification time


Hi all,

I am beginner in bash programming and I am trying to write a script thet retrieves and stores inside some of
its local variables a modification time ( or a size ) of a given file. Are there any syscalls, or other methods to achieve above written ?

Thank you.
 
Old 12-18-2006, 07:09 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,354
Blog Entries: 55

Rep: Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541
"stat -c "%s %Y" /some/file" will give you the size in bytes and mtime in epoch.
 
Old 12-18-2006, 07:10 PM   #3
kassle
Member
 
Registered: Jan 2006
Distribution: bodhi
Posts: 44

Rep: Reputation: 15
try

byTime=`ls -l [files] | awk '{ print $6:$7 }'
bySize=`ls -l [files] | awk '{ print $5:$7 }'
 
Old 12-19-2006, 05:48 AM   #4
_cih_
LQ Newbie
 
Registered: Nov 2006
Posts: 4

Original Poster
Rep: Reputation: 0
thanks

Thanks for help !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Get file modification date/time in Bash script cmfarley19 Programming 16 04-15-2015 06:25 PM
time stamp for file modification youngstorm Linux - Newbie 2 11-01-2005 03:46 PM
File size vs Play time in cdrecord Dr. Psy Linux - Software 3 06-28-2005 08:41 AM
Warning: File 'sendmail.cf' has modification time in the future G-Rad Linux - Newbie 0 03-06-2004 11:09 PM
perl, Net::Ftp, and Novell file modification time neo77777 Programming 0 01-30-2003 09:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration