1
vote
3answers
38 views

How do I set a file's mtime in epoch format?

I know how to get a file's mtime in epoch format: stat --format=%Y <file> But I have not been able to figure out how to set a file's mtime in epoch format. The touch(1) man page appears to ...
2
votes
4answers
68 views

Get the latest directory (not the latest file)

My folder parent has the following content: A.Folder B.Folder C.File It has both folders and files inside. B.Folder is newer. Now I just want to get B.Folder, how could I achieve this? I tried ...
2
votes
2answers
93 views

How to change “date modified” of multiple folders, to be the same of that of a .mkv that's inside each one, using Cygwin

How to change "date modified" of multiple folders to be the same of that of the .mkv that's inside each one. eg. there's folder1 which contains a file 1.mkv folder1: 2/17/14 1.mkv: 1/6/12 I want ...
1
vote
1answer
26 views

Timestamp ts not working with thinkfan

I wanted the output of thinkfan -n output with a timestamp next to it so I can later analyse the patterns, and found this question: Prepending a timestamp to each line of output from a command, which ...
2
votes
5answers
72 views

How to copy 5 newest files from one directory to another and delete the old copies

How can I copy the 5 newest files from a directory to another in a "new to old" order.
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 ...
1
vote
1answer
394 views

rename files maching specific mtime value within directory

I use simple set of shell commands to in order to create mysqldumps daily. The script is called by cron daemon. It looks like: presentdate="`date +%d-%m-%Y_%H:%M.%S`" basedir="/var/db_my_backup" ...
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 ...
2
votes
4answers
700 views

Access the last file (alphabetically) in a directory

I'm trying to open a file with vim from the command line, the file is in a directory filled with automatically generated files that are prepended with a time stamp. Since I don't know the time stamps ...
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?
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?
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: ...