The tag has no wiki summary.

learn more… | top users | synonyms

66
votes
15answers
11k views

What are the legitimate uses of the `touch` command?

What's the point of the touch command? I know I can create empty files with it, but so is also the case with echo -n. Otherwise, why would someone need to change the timestamps of a file? Unless to ...
33
votes
3answers
99k views

Get file created/creation time? [duplicate]

Possible Duplicate: How do I do a ls and then sort the results by date created? Is there a command in Linux which displays when the file was created ? I see that ls -l gives the last ...
27
votes
2answers
20k views

How do I do a ls and then sort the results by date created?

In what order are the dated ordered by? Certainly not alphanumeric order. ls -lt sorts by modification time. But I need creation time.
19
votes
2answers
5k views

Prepending a timestamp to each line of output from a command

I wish to prepend a timestamp to each line of output from a command. For example: foo bar baz would become [2011-12-13 12:20:38] foo [2011-12-13 12:21:32] bar [2011-12-13 12:22:20] baz ...where ...
18
votes
5answers
12k views

How to find creation date of file?

I want to find out the creation date of particular file, not modification date or access date. I have tried with ls -ltrh and stat filename.
17
votes
3answers
2k views

How does touch -t work internally?

How does touch -t command works exactly, internally (I tried to find its source code but couldn't)?
16
votes
4answers
913 views

Finding command execution time in hindsight

I've just executed a long-running process from the bash prompt. In hindsight, I wish I'd run time on it, or noted down the time at which I kicked it off. Is there any way of getting this information ...
14
votes
3answers
5k views

How to list files that were changed in a certain range of time?

How can I list recursively all files that were changed between 22.12.2011 and 24.12.2011?
14
votes
2answers
792 views

How long is the password for executing a command with sudo cached?

If I run a command which requires root privileges with sudo, I will be asked to enter the current user's password. After that for a while, if I execute the same sort of commands with sudo, I won't be ...
14
votes
5answers
6k views

How can I do a “copy if changed” operation?

I would like to copy a set of files from directory A to directory B, with the caveat that if a file in directory A is identical to a file in directory B, that file should not be copied (and thus its ...
13
votes
6answers
7k views

Correlating /var/log/* timestamps

/var/log/messages, /var/log/syslog, and some other log files use a timestamp which contains an absolute time, like Jan 13 14:13:10. /var/log/Xorg.0.log and /var/log/dmesg, as well as the output of $ ...
11
votes
3answers
2k views

What file systems on Linux store the creation time?

Are there any (good known, reliable) file systems on Linux that store the creation time of files and directories in the i-node table? If there are, is the "changed" time replaced by the creation ...
10
votes
4answers
2k views

Preserve modified time stamp after edit

For files within a specific folder, I would like vim to never touch "modified" timestamp at all. The background is that I use Bloxsom for blogging, which uses plain text files in ~/bloxsom as source ...
9
votes
4answers
6k views

How to get milliseconds since Unix epoch?

I want to do a bash script that measures the launch time of a browser for that I am using an html which gets the time-stamp on-load in milliseconds using JavaScript. In the shell script just before i ...
8
votes
6answers
7k views

Shell script for moving oldest files?

How do I write a script for moving just the 20 oldest files from one folder to another? Is there a way to grab the oldest files in a folder?
7
votes
7answers
1k views

timestamp before an echo

Exists a nicer way to create timestamp in front of an echo? Currently I do it this way: #!/bin/sh if mount | grep -q /mnt/usb; then echo `date +%R\ ` "usb device already mounted" else ...
7
votes
3answers
6k views

How do I change folder timestamps recursively to the newest file?

I was wondering if anyone knows how to change the timestamps of folders recursively based on the latest timestamp found of the files in that folder. So for example: ...
7
votes
2answers
161 views

What counts as a file modification or change?

Does renaming affect the file modify or access time? Is there a list somewhere of what changes which times?
7
votes
2answers
5k views

How to find difference between two timestamps up to milliseconds?

I am new to shell scripting. The heart of my script is to find the difference between two timestamps up to milliseconds. With me I have a file with content of timestamps only as 2012-09-13 ...
6
votes
2answers
792 views

What can you do to a file without triggering the “Change” Timestamp?

What can you do to a file without triggering the "Change" stat? For instance, it appears that simply changing a bit will trigger Change.
6
votes
7answers
2k views

Bash, remove oldest files

I`m trying to delete old files from directory and leave only 3 newest files. cd /home/user1/test while [ `ls -lAR | grep ^- | wc -l` < 3 ] ; do rm `ls -t1 /home/user/test | tail -1` ...
6
votes
1answer
2k views

How do I get the difference between two timestamps?

I am creating a simple backup script. I would like to have a message saying "You last backed up x days ago" on login. I can create a file when I do the backup "backup/.last_backup_timestamp" but what ...
5
votes
2answers
1k views

Why does Unix store timestamps in a signed integer?

Why is a signed integer used to represent timestamps? There is a clearly defined start at 1970 that's represented as 0, so why would we need numbers before that? Are negative timestamps used anywhere? ...
5
votes
4answers
2k views

Changing the timestamp of a symlink

I know how to change the timestamp of a regular file: touch -t 201301291810 myfile.txt I was not able to do the same with a symlink. Is it possible? Distro: RHEL 5.8
5
votes
1answer
990 views

Get “date” to understand a timestamp phrase of a different language

My web-scraping scripts have long enjoyed using date -d to read in human-formatted time and date stamps like "March 11, 1999" and convert to any other format I need via the -s parameter. How might I ...
5
votes
1answer
1k views

On what occasion will inode change?

I checked manual of find , and there's an option -ctime which specify the last modification time of inode. But on what occasion would inode change ? When is that option useful ?
5
votes
1answer
223 views

What does the “00:00:00” timestamp mean in kern.log?

I'm looking for causes of a particular problem in kern.log. There are many entries with a 00:00:00 timestamp: Jun 11 00:00:00 mymachine kernel: [ 0.000000] Initializing cgroup subsys cpusetJun 11 ...
4
votes
1answer
455 views

How to understand the unix time format?

How does the Unix time format work? For example, the Unix time for 3:00 PM is: Normal time format <----3:00PM = 1402565420----> Unix Time How can I make it understand the time as 3:00 PM ?
4
votes
4answers
2k views

Convert Unix timestamp into human-readable format on AIX

I need to convert unix timestamp (number of seconds since 1970, e.g. 1381260225 is Tue Oct 8 19:23:45 GMT 2013) into a standard human-readable format. I could get some answers by googling but those ...
4
votes
2answers
96 views

In Linux Fedora, How can I select files to move by time interval

How can I select and move files that were written in a specified time interval, such as 1530 to 1730 local time on a recent date? Background: I use Linux Fedora 12, and I have made my first, and long ...
4
votes
2answers
229 views

Sort files by modification time

I've seen many questions and answers here using a construction along the lines of list_dir=`ls -t /path/to/dir/` for i in $list_dir; do or ls -t | while read i; do Now, I know that you shouldn't ...
4
votes
5answers
16k views

Display time stamp in dd/mm/yyyy_hh:mm:ss:ms in Unix or Linux

I need help to display date and time in desired format in Unix/ Linux. My desired format is: dd/mm/yyyy hh:mm:ss:ms in Unix or Linux. I got close using the following command: echo $(date +%x_%r) ...
4
votes
2answers
1k views

Determine file system timestamp accuracy

File timestamps accuracy is limited to one second for EXT3, one microsecond for UFS, and one nanosecond for EXT4 (at least according to experience). Is there any way to determine this based only on ...
4
votes
2answers
249 views

Extract timestamp from a gzip file

How can I know the raw original timestamp of a file foo compressed with gzip without having to decompress foo.gz? gzip --verbose --list foo.gz and file foo.gz will print formatted date and time.
4
votes
1answer
435 views

Only use mtime comparison with rsync?

Is it possible to sync files via rsync and let rsync only compare mtime informations? Or is there another tool for this job? That means that such a tool only copies src to destination if the src is ...
4
votes
3answers
195 views

What could be the use case of changing modified time of a file to the future?

I was reading through the man page of ls on UNIX, specifically OS X Mavericks. This got me intrigued: If the modification time of the file is more than 6 months in the past or future, then the ...
3
votes
3answers
5k views

How can I change 'change' date of file?

How can I change 'change' date? $ touch -t 9901010000 test;stat test File: `test' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fe01h/65025d Inode: 11279017 ...
3
votes
4answers
1k views

Modification and Access time of a file?

Is it possible to change the file modification time without changing the file acess time?
3
votes
2answers
224 views

Identify and assign most recent file to shell variable

I have a directory of .jpg files that continuously grows. I want to copy the most recent one elsewhere. This is what I currently have and it works, just curious if there's a better way to identify the ...
3
votes
3answers
2k views

Delete files based on year

I need to delete all files in a directory that were created in 2009. What command can I use to do that?
3
votes
3answers
64 views

How to display the time of sadf in epoch format

I have a problem in sadf between ubuntu and centos. The thing is how the date is displayed in both. Ubuntu: root@db1:/usr/local/nagios/libexec/nrpe_local# sadf | head -10 ...
3
votes
3answers
2k views

How can I change the date modified of a folder to the last changed file inside? [duplicate]

In my media center directory all modified times of my folders are somehow not the desired date. How can I change all modified times of the main folders to the modified time of the newest media-file ...
3
votes
2answers
4k views

list all files newer than given timestamp and sort them

I want to list all files (sorted by date) that are newer than timestamp in format 20130207003851 in directory /tmp only. Subdirectories can be omitted. Using SUSE Linux Enterprise Server 11. The ...
3
votes
1answer
1k views

See if file has been copied to USB

Is there a way to see if a file has been copied to an USB drive? (Ex: I have the file secret.db and I suppose that my friend has copied it into his USB drive. With stat $filename I cannot see the ...
3
votes
2answers
371 views

On touching a new file why is mtime and ctime older than atime?

I have this: $ ls -l ff ls: cannot access ff: No such file or directory $ touch ff $ stat ff File: `ff' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: ...
3
votes
1answer
226 views

Cron job to delete files older than 3 days

I need to remove files older than 3 days with a cron job in 3 different directories. (these 3 directories are children of a parent directory /a/b/c/1 & /a/b/c/2 & /a/b/c/3) Can this be done ...
3
votes
1answer
59 views

How does the system know when a file has been modified? In particular memory mapped files

If I am looking at a process from outside the process how can I tell which files it modifies? One thing I can do is track calls to write, but a process can map a file to memory and write to the ...
3
votes
2answers
81 views

Is there any mitigation against touch date/time forgery?

I have been using touch -t to change time of a file when I started using Linux, is there any mitigation against touch date/time forgery? Like, echoing original created date and time, even after using ...
3
votes
3answers
37 views

Moving latest files from one directory to another

I'm trying to move newest files from one directory to another directory. The find command finds the files but not moving them to another directory. The destination directory exists. $ cd ...
3
votes
1answer
131 views

timestamp of newly created file is in the future

On my machine at work I experience weird timestamps of files. This is bothering me, because it messes with make. To reproduce the issue, this suffices: $ touch foo $ stat -c %y foo 2014-01-31 ...