appending timestamp to a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers appending timestamp to a file
# 1  
Old 03-02-2007
appending timestamp to a file

hi freinds,

i need to append timestamp to a file name to make it unique...
do we have any command in unix to do

please help Smilie
# 2  
Old 03-02-2007
Code:
timestamp=$( date +%d%m%y%H%M%S )
mv filenm filename"$timestamp"

This User Gave Thanks to anbu23 For This Post:
# 3  
Old 03-02-2007
to make it unique
one more

%s seconds since `00:00:00 1970-01-01 UTC' (a GNU extension)

Code:
date '+%s'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. Shell Programming and Scripting

Appending timestamp to a file. Why do I need this space ?

Version Info $ cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.4 (Tikanga) $ $ echo $0 -ksh I was trying to append date to the file name. The following syntax has worked $ touch HELLO-`date '+%d-%b-%Y'`.txt $ ls -alrt HELL* -rw-r--r-- 1 rlapp oinstall 0 Feb 20... (2 Replies)
Discussion started by: John K
2 Replies

5. 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

6. Shell Programming and Scripting

Appending unix timestamp to every line of a statistical file

I have a statistical file populating every minute as below: 2011-11-11-1108 1955 891 2011-11-11-1109 2270 1049 2011-11-11-1110 1930 904 2011-11-11-1111 2030 931 2011-11-11-1112 1944 900 2011-11-11-1113 1922 875 Instead of having the date and time in the given format (2011-11-11-1113) I... (10 Replies)
Discussion started by: thinktank
10 Replies

7. 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

8. Shell Programming and Scripting

Appending number of lines in the file to begining of the file

I am having 6 files named file1,file2....file6 and i need to append number of lines in each file to begining of the file. For example, If file 1 contains a b c d then after adding new line file1 should contain 4 a b c d Thanks in advance. (2 Replies)
Discussion started by: akhay_ms
2 Replies

9. UNIX for Dummies Questions & Answers

Appending timestamp problem

Hi, I am trying to insert a timestamp after all the file names in a folder,after the timestamp is created in the filename the file size is becoming zero bytes. please tell me where I am doing it wrong. I have declared the variable in starting of my script. timestamp=`date... (1 Reply)
Discussion started by: shruthidwh
1 Replies

10. 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
Login or Register to Ask a Question