473,854 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to know AGE of a file

12 New Member
Hi,

I have a file... how to know that file is 10 days old. In other words... want to check a file whether it NOT touched for modifications since 10 days.

I want to use in korn shell script.

Thanks in advance.
Mar 15 '07 #1
5 13576
michaelb
534 Recognized Expert Contributor
ls -l displays the time of the last modification.

If you need to programmaticall y collect files based upon the last mod. time look at the UNIX find command, and specifically at the-mtime option.
Mar 16 '07 #2
trs204
12 New Member
thank you.
Mar 19 '07 #3
thescripter75
1 New Member
To calculate the age of a file, e.g. within another script, it can be a little tricky to use only the present date and long listing of the file, as the date might have changed / the month / the year, etc.
Then it is handy to use Epoch Time (seconds since New Year 1970)
and compute the difference between the present E.T. and E.T. of the modification of the file, like this

tnow=`date +%s`
tfile=`date +%s -r filename`
agesecs=$(($tno w-$tfile)) #Age of filename in seconds
ageminutes=$(($ agesecs/60)) #Age in minutes
May 29 '07 #4
Nick Keeman
4 New Member
I Like the post of thescripter75 but it will only work in 'Linux' for most other Unix flavours this won't work as they are ages behind.

regards,

Nick
Jun 13 '07 #5
JosephUniverse
1 New Member
It works on HPUX B.11.23 or higher
Mar 8 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

13
2620
by: ebobnar | last post by:
I've written a link aliasing script that allows users to rewrite urls on their web pages. The crux of the script is the following: if(getimagesize($redirect_to) == 0) header("Location: $redirect_to"); else include("$redirect_to"); Which uses getimagesize() to determine if the link specified in $redirect_to points to an image (i.e img src) in which case it should
4
3663
by: pdav | last post by:
Hi! Is there any solution to create a directory with one script with mkdir(), and then write a file (or move an uploaded file) in this directory with another script? The problem is, that the directory belongs to the PHP-interpreter (UID 33 in my case) and the script doing the file creation and the one creating the directory belong to the FTP-user (UID 754 in my case).
14
2586
by: Xah Lee | last post by:
Just bumped into another irresponsibility in perl. the crime in question this time is the module File::Basename. Reproduction: 1. create a directory containing a file of this name: "cdrom.html". 2. "use File::Basename;", with the line: ($name,$path,$suffix) = fileparse($File::Find::name, ('.html', '.m'));
9
3214
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is indeed also true for our language of choice, Python. Its file type allows some extraordinary convenient access like: for line in open("blah"): handle_line(line)
11
3666
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own rules when it comes to file paths. A lot of Microsoft installers for example, and also installers of other companies, do not work because they handle paths in the following manner:
1
12793
by: Joshua Ammann | last post by:
Hello, I'm trying to export a query containing contact information, including a field. Some zip codes have one or two leading zeros, for example, San Juan, PR (00927) and Springfield, MA (01104). When I export to a comma separated value (.csv) file, the zip code for San Juan becomes "927" and for Springfield becomes "1104". How can I prevent the leading zero(s) from being trimmed in the exported .csv file? Because the table contains...
7
1857
by: Ajit | last post by:
Is there anyway to check for existance of a file on different machine. i.e. we have a data file (text file) thats stored on some other machine as its not to be exposed in case the web server is hacked. and we want to update data from this text file into our database. I know file object but it works only locally.(i.e. work with files stored on local drive) If anyone could help me it will be great.
9
8400
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. However, after I alter the table and open microsoft excel to look at any changes; I get the following error: "This file is not in a recognizable format" If I do open the file in excel it looks like its not formatted.
12
13744
by: freeseif | last post by:
Hi programmers, I want read line by line a Unicode (UTF-8) text file created by Notepad, i don't want display the Unicode string in the screen, i want just read and compare the strings!. This code read ANSI file line by line, and compare the strings What i want Read test_ansi.txt line by line
9
1567
by: ggcdc | last post by:
Hello, i want to ask can i use php to get a file name, for example, i uploaded two file called - abc.php, dfg.php on my server, once i go to the page - abc.php , something like a window or other will blow out and say : you are on abc.php page. then when i go to the page - dfg.php , as same, something like a window or other will blow out and say : you are on dfg.php page.
0
9902
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10764
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10371
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9524
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5753
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5945
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.