Sponsored Content
Top Forums UNIX for Dummies Questions & Answers File renames with timestamp urgent Post 302157305 by Smiling Dragon on Thursday 10th of January 2008 05:29:50 PM
Old 01-10-2008
I'd suggest you not use '/' in the filename as it's the unix character to delimit directories.
A popular timestamp is this:
yyyymmdd.hhmmss
That way round means that it will be sorted by file first, then in date order.

The date command will output the info you want, call it as follows to get the format you specified below:
Code:
date +%d\/%m\/%y_%H\:%M\:%S

To get the format I've suggested:
Code:
date +%Y%m%d.%H%M%S

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting a relative timestamp from timestamp stored in a file

Hi, I've a file in the following format 1999-APR-8 17:31:06 1500 3 45 1999-APR-8 17:31:15 1500 3 45 1999-APR-8 17:31:25 1500 3 45 1999-APR-8 17:31:30 1500 3 45 1999-APR-8 17:31:55 1500 3 45 1999-APR-8 17:32:06 1500 3 ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

2. Shell Programming and Scripting

I need a korn shell script that renames and copies

I have 68 servers whose /etc/ntp.conf file have the wrong NTP server name and they need to be updated with a different or correct NTP server name. I am doing this on AIX Here is what I would like. and I would need a script that would rename the old /etc/ntp.conf and add a date stamp to it ... (1 Reply)
Discussion started by: jesifra
1 Replies

3. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

4. Shell Programming and Scripting

Identifying files with a timestamp greater than a given timestamp

I need to be able to identify files with file timestamps greater than a given timestamp. I am using the following solution, although it appears to compare files at the "seconds" granularity and I need it at the milliseconds. When I tested my solution, it missed files that had timestamps... (3 Replies)
Discussion started by: nkm0brm
3 Replies

5. Shell Programming and Scripting

Urgent ...pls Sorting files based on timestamp and picking the latest file

Hi Friends, Newbie to shell scripting. Currently i have used the below to sort data based on filenames and datestamp $ printf '%s\n' *.dat* | sort -t. -k3,4 filename_1.dat.20120430.Z filename_2.dat.20120430.Z filename_3.dat.20120430.Z filename_1.dat.20120501.Z filename_2.dat.20120501.Z... (1 Reply)
Discussion started by: robertbrown624
1 Replies

6. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

7. Shell Programming and Scripting

Lftp sftp get - script renames the local file with suffix tilde

Hi, Below script used for sftp get, #/bin/bash USER=xxx PASS=xxx HOST=xxx REMOTE_FILE=$1 LOCAL_FILE_LOC=$2 cd $LOCAL_FILE_LOC lftp sftp://$USER:$PASS@$HOST:10022 -e "get $REMOTE_FILE; bye" If file does not exist in sftp server, and file (same as remote file name) exists in local dir,... (4 Replies)
Discussion started by: vhegde1011
4 Replies

8. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

Hello , I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies

9. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

10. Shell Programming and Scripting

Grep lines between last hour timestamp and current timestamp

So basically I have a log file and each line in this log file starts with a timestamp: MON DD HH:MM:SS SEP 15 07:30:01 I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies
GMSTRFTIME(3)								 1							     GMSTRFTIME(3)

gmstrftime - Format a GMT/UTC time/date according to locale settings

SYNOPSIS
string gmstrftime (string $format, [int $timestamp = time()]) DESCRIPTION
Behaves the same as strftime(3) except that the time returned is Greenwich Mean Time (GMT). For example, when run in Eastern Standard Time (GMT -0500), the first line below prints "Dec 31 1998 20:00:00", while the second prints "Jan 01 1999 01:00:00". PARAMETERS
o $format - See description in strftime(3). o $timestamp - The optional $timestamp parameter is an integer Unix timestamp that defaults to the current local time if a $timestamp is not given. In other words, it defaults to the value of time(3). RETURN VALUES
Returns a string formatted according to the given format string using the given $timestamp or the current local time if no timestamp is given. Month and weekday names and other language dependent strings respect the current locale set with setlocale(3). EXAMPLES
Example #1 gmstrftime(3) example <?php setlocale(LC_TIME, 'en_US'); echo strftime("%b %d %Y %H:%M:%S", mktime(20, 0, 0, 12, 31, 98)) . " "; echo gmstrftime("%b %d %Y %H:%M:%S", mktime(20, 0, 0, 12, 31, 98)) . " "; ?> SEE ALSO
strftime(3). PHP Documentation Group GMSTRFTIME(3)
All times are GMT -4. The time now is 08:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy