Adding timestamp to all inbound files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding timestamp to all inbound files
# 1  
Old 07-08-2010
Adding timestamp to all inbound files

hi,
can someone give me a sample shell scripts to make all inbound files will a have a Moveit timestamp.I think MoveIt is a server,thanks.
# 2  
Old 07-08-2010
Hi Sonja,

You need to give more information.

Where are your files coming from?
Where do you want the timestamp? In the filename? Appended to the file? In a logfile?

I don't know what MoveIt is. If no one answers, maybe no one else does either.
# 3  
Old 07-08-2010
hi ken, thanks for the response,I have to modify my shell script to append timestamp to all inbound files.

---------- Post updated at 08:11 PM ---------- Previous update was at 08:02 PM ----------

# Archive File
echo "Archiving $File."
mv $FullPath/$FileName $ArchDir/${FileName}.${datestamp}
RetCode=$?
if [ $RetCode -ne 0 ]
then
echo "Not enough permission to move the file $FileName."
mv $ParamTmp $ParamFile
cd -
exit 1
else
echo "Was able to successfully archive the file $FileName."
fi

count=`echo $count + 1 |bc`
fi
# 4  
Old 07-08-2010
OK, you said append. So these are text files and you want to add one more line of text with the timestamp, right?

Run man date and pick a format you like. Then run a command like this:
Code:
date +%c >> filename
or
date "+%F %T" >> filename



---------- Post updated at 09:19 PM ---------- Previous update was at 09:13 PM ----------

OK, to put the date in the filename, try this:
Code:
mv $FullPath/$FileName $ArchDir/${FileName}.$(date +%Y%m%d)

BTW, you can increment count like this:
Code:
((count++))

# 5  
Old 07-08-2010
hi ken,
thanks again...
how can i append a timestamp to the file,i just only show you the date,
is it something like this...

datestamp=`date +"%Y%m%d.%H%M"`

and for timestamp..

timestamp=$( date +%d%m%y%H%M%S )
should i only chnage the datestamp to timestamp on this...?

mv $FullPath/$FileName $ArchDir/${FileName}.${timestamp}
please correct me if I'm wrong..
ken
thank you...=)
# 6  
Old 07-08-2010
You have to decide what format you want for the timestamp and/or datestamp.

%Y is the 4-digit date,
%H is the (24-hour) hour, etc.

You can see all the format options by executing man date and scrolling down to the list.
And you can experiment right on the command line to see what it would look like. e.g.:
date +%H%M%S
This User Gave Thanks to KenJackson For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a timestamp every N row in another column

Hi, i have a raw output file like this 167,63.50 167,63.50 168,63.68 166,63.68 168,63.68 I would like to add every each N rows (for example 60) and in a third column , a timestamp using the command date +"%H:%M"how can i do it with one single command ? Thank you !! (5 Replies)
Discussion started by: Board27
5 Replies

2. Shell Programming and Scripting

Mailx - Adding timestamp in CSV file

Hi allI am mailing csv file to our lotusnote server using shell script. I am using command to get require date/time :date +"%d%b%y-%X%p"File name is :TESTFILE-29Jan14-09:00:00AM.csv.When I am receving this on lotusnote server coming as "00AM.csv" rest of the string is getting truncated. I feel due... (1 Reply)
Discussion started by: krsnadasa
1 Replies

3. UNIX for Dummies Questions & Answers

Move Multiple Files adding date timestamp before file type

There are files in a directory and I have to move multiple files adding datetimestamp before the file type. /Data/ abc.csv def.csv ghi.csv I have to move this files to archive directory adding datatimestamp before .csv /archive/ abc_YYYYMMDDHHMMSS.csv def_YYYYMMDDHHMMSS.csv... (7 Replies)
Discussion started by: eskay
7 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

sort the files based on timestamp and execute sorted files in order

Hi I have a requirement like below I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory My files looks like this PGABOLTXML1D_201108121235.xml... (1 Reply)
Discussion started by: saidutta123
1 Replies

6. Shell Programming and Scripting

Adding timestamp after cat <<EOF >

Hi Team, I am trying to add timestamp to SQLs by taking the timestamp in variable through shell script.I started like this. cat << EOF > $MYDIR CONNECT TO $MYDB USER $MYUSR USING $MYPWD; T=`db2 -x "select CURRENT_TIMESTAMP from sysibm.sysdummy1 "`; DECLARE RECCUR CURSOR FOR... (3 Replies)
Discussion started by: rocking77
3 Replies

7. AIX

disable inbound mail for AIX 5.3

Hi All, How do I disable inbound mail for AIX 5.3 server? I just need the outbound mail. It's using the native sendmail program. Thank you! (1 Reply)
Discussion started by: itik
1 Replies

8. HP-UX

to get the timestamp of files from the files and folders in Unix

Hi, I had a directory and many subdirectories and files with in it. Now i want to get the timestamp of files from the files and folders recursively. :( Please help me to generate a script fort he above mentioned requirement! Appreciate for ur qick response Thanks in advance! ... (2 Replies)
Discussion started by: kishan
2 Replies

9. Shell Programming and Scripting

Processing inbound mail

Hi All Has anyone written any script that would listen for inbound mail and based on its subject process the body ? Thx J (3 Replies)
Discussion started by: jhansrod
3 Replies

10. IP Networking

check inbound traffic on ports

Hello, I'm new to the forum and would like to know how to check inbound traffic on various port numbers. I would also like to know how to open and close various ports on a unix box running solaris 8. Thanks in advance. sunoracle (2 Replies)
Discussion started by: sunoracle
2 Replies
Login or Register to Ask a Question