05-29-2013
In case you are not aware, -mtime -1 is not constrained to "a file that was generated today." It will match anything that's less than 24 hours old, which usually includes a portion of yesterday.
If the file must have been created on the current calendar day, perhaps you'd be better off using the date command to generate a filename pattern argument for the -name primary.
Regards,
Alister
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to rename the last generated file in a given directory using a makefile.
If I type 'make build' the 'build' target produces a file (ie: text_001.txt). It automatically generates them sequentially, so I don't have control over the name. I can't say that it will always be text_001.txt.... (2 Replies)
Discussion started by: pieter023
2 Replies
2. Shell Programming and Scripting
Hi,
Can anyone plz share their experience with -
Building shell script to append the file with date in following format-
Filename_MMDDYYYY.txt
Thanks in advance (2 Replies)
Discussion started by: prince_of_focus
2 Replies
3. UNIX for Dummies Questions & Answers
Hi I am very new to scripting,
Can someone show me how to (in unix shell script) compare the system's date with a date in a file. The requirement is to somehow open this file (which will only have a date in it) and compare it with today's date. If they are equal execute a procedure below but if... (4 Replies)
Discussion started by: siog
4 Replies
4. UNIX for Dummies Questions & Answers
How to list all the files which are not generated today, and move all the above files to backup dir. (2 Replies)
Discussion started by: redlotus72
2 Replies
5. Shell Programming and Scripting
I am a newbie to scripting.
I need a korn shell script to copy log files of current day to archive folder and rename with current days date stamp.
I would really appreciate your help.
File structure is as follows. Everyday files get overwritten, so I need copy to a archive directory and... (3 Replies)
Discussion started by: mdncan
3 Replies
6. Shell Programming and Scripting
Hi Guys,
I was working some time ago n was in need to calculate date 30/31 days from today including Feb (Leap yr stuff). Today date is variable depending on day of execution of script. I tried searching but was not able to get exactly what I needed....So at that I time I implemented by my own... (3 Replies)
Discussion started by: coolgoose85
3 Replies
7. Shell Programming and Scripting
I would like to find the Files which are generated today in the current directory:
I use the commad ls -lrt * | egrep " `date "+%b"` * `date "+%d"`
to acheive this. Is there any better way to acquire the same.
Multiple answers will be great. Thanks (3 Replies)
Discussion started by: kusathy
3 Replies
8. Shell Programming and Scripting
Hi
I have file with number status and date1 and date1 field,
want add a column today between column date1 and date2.
file1.txt
number status date1 date2
===== ==== === =====
34567 open 27/06/13 28/06/13
45678 open 27/06/13 28/06/13
43567 open 27/06/13 28/06/13 ... (1 Reply)
Discussion started by: vijay_rajni
1 Replies
9. Shell Programming and Scripting
This is on a CentOS box, I have two scripts that need to run in order.
I want to write a shell script that calls the first script, lets it run and then terminates it after a certain number of hours (that I specify of course), and then calls the second script (they can't run simultaneously) which... (3 Replies)
Discussion started by: btramer
3 Replies
10. UNIX for Beginners Questions & Answers
Hi Community!
Following on from this code in another thread:
#!/bin/bash
file_string=`/bin/cat date.txt | /usr/bin/awk '{print $5,$4,$7,$6,$8}'`
file_date=`/bin/date -d "$file_string"`
file_epoch=`/bin/date -d "$file_string" +%s`
now_epoch=`/bin/date +%s`
if
then
#let... (2 Replies)
Discussion started by: Greenage
2 Replies
RENAME(3) 1 RENAME(3)
rename - Renames a file or directory
SYNOPSIS
bool rename (string $oldname, string $newname, [resource $context])
DESCRIPTION
Attempts to rename $oldname to $newname, moving it between directories if necessary. If $newname exists, it will be overwritten.
PARAMETERS
o $oldname
-
Note
The old name. The wrapper used in $oldname must match the wrapper used in $newname.
o $newname
- The new name.
o $context
-
Note
Context support was added with PHP 5.0.0. For a description of contexts, refer to "Streams".
RETURN VALUES
Returns TRUE on success or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.1 | |
| | |
| | rename(3) can now rename files across drives in |
| | Windows. |
| | |
| 5.0.0 | |
| | |
| | rename(3) can now also be used with some URL |
| | wrappers. Refer to "Supported Protocols and Wrap- |
| | pers" for a listing of which wrappers support |
| | rename(3). |
| | |
| 4.3.3 | |
| | |
| | rename(3) may now be able to rename files across |
| | partitions on *nix based systems, provided the |
| | appropriate permissions are held. Warnings may be |
| | generated if the destination filesystem doesn't |
| | permit chown() or chmod() system calls to be made |
| | on files -- for example, if the destination |
| | filesystem is a FAT filesystem. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
Example with rename(3)
<?php
rename("/tmp/tmp_file.txt", "/home/user/login/docs/my_file.txt");
?>
SEE ALSO
copy(3), unlink(3), move_uploaded_file(3).
PHP Documentation Group RENAME(3)