Appending timestamp problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Appending timestamp problem
# 1  
Old 06-13-2011
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.

Code:
timestamp=`date '+%Y%m%d%H%M%S'`
Src_fdr=$edw/ntr/tog 

cd $Src_fd


find $SOURCE_FOLDER -name '*.csv' | while read FILENAME
do
      < "$FILENAME" >   "${FILENAME}#"$timestamp".csv"  
done

Regards,
Shruthi
# 2  
Old 06-13-2011
Smilie
Code:
% FILENAME=file.csv
% timestamp=00.00.00
% echo "${FILENAME}#"$timestamp".csv"   
file.csv#00.00.00.csv

And #00.00.00.csv is commentary so you redirect in the original file.

You do not need redirection in this task at all. Try this

Code:
find $SOURCE_FOLDER -name '*.csv' | while read FILENAME; do
       echo mv "$FILENAME" "${FILENAME%.csv}-$timestamp.csv"
done

and see whether everything is alright.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with Timestamp

Hi Team, i need some help on finding one hour back time. if current time is 5:18:22 means i have to find 4:18:22 i am having scenario to pull record which as got inserted morethan one hour back in table time stamp is 2014-12-22 05:15:13.788875 can any one help me on this Thanks Vij (5 Replies)
Discussion started by: bhaskar v
5 Replies

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

3. UNIX for Dummies Questions & Answers

Timestamp problem

I have a date/timestamp problem I can't figure out. I have an Oracle table with a column DEL_TIMESTAMP defined as a NUMBER. The min and max values in the column are: 6.3417E+17 6.3470E+17 the bottom value is: 634700000000000000 Is this the time since the epoch? How does this represent... (2 Replies)
Discussion started by: djehres
2 Replies

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

5. Shell Programming and Scripting

sed appending problem

i have a number of java files containing eg: --------------myfile.java-------------- package zip.fun.myfiles; import java.* import something..; import sdfdfdsa; ... ... -------------------------------------------- Now I need to append / insert a line as follows: ... (10 Replies)
Discussion started by: linuxadmin
10 Replies

6. Shell Programming and Scripting

Problem with appending a file!

Hi All, I have a script which i use in office. This script is used to log the work in users name. For that in the script itself I have added that the infomration should append to the logfile everytime the script is run. LOGFILE=/data/log/request1.txt All these days it was... (3 Replies)
Discussion started by: smarty86
3 Replies

7. Solaris

Problem in appending the correct log

Hi All, I have a perl module TrxLog.pm and following are codes in it #!/usr/local/bin/perl package TrxLog; %log_begin=""; %log_end=""; %log_msg=""; %log_start_time=""; %log_end_time=""; $ix=0; @arr_msg=""; if (! -e "TrxLog.txt"){ open (TRX,">TrxLog.txt"); }else{ ... (1 Reply)
Discussion started by: megh
1 Replies

8. Shell Programming and Scripting

Can someone kindly help with appending problem!!!

Hi guys,i urgently need help in this problem,i need to append one sentence to another line when it meet a certain word. For example: root: root time_last_login = 1191232080 root tty_last_login = /dev/vty0 root host_last_login = rep1nim root unsuccessful_login_count = 0 root... (10 Replies)
Discussion started by: cyberray
10 Replies

9. UNIX for Dummies Questions & Answers

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 :confused: (2 Replies)
Discussion started by: madhu_aqua14
2 Replies

10. Shell Programming and Scripting

timestamp problem

hi, from a shell script I am copying 2 different set of files in 2 different directories and then it ftp the same set files to another server 2 different directories. the dest directories where it is copying the files own by a different user and required permission is there... (0 Replies)
Discussion started by: sankar
0 Replies
Login or Register to Ask a Question