[Solved] Adding time stamp to file name

I have the awk

awk -F\* '$1=="ST",$1=="SE"{if($1=="ST"){close(f);f="sample" ++i} ; $1=$1; print>f}' OFS=\| <filename>

How to add the time stamp to the file name mentioned as "sample"

What format should the timestamp follow?

TIMESTAMP=$( date +%m%d%y.%H%M%S )
FILE="${FILE}.${TIMESTAMP}"

I want the time format as

date +%m%d%y%H%M%S. 

I tried the suggested way, but when doing it I got the files generated as

${FILE}.${TIMESTAMP}3
${FILE}.${TIMESTAMP}2
${FILE}.${TIMESTAMP}1

Try:

awk -F\* -vt=`date +%m%d%y%H%M%S` '$1=="ST",$1=="SE"{if($1=="ST"){close(f);f="sample"t"" ++i} ; $1=$1; print>f}' OFS=\| <filename>

Wonderful, It worked !!!

Thanks a ton.

Hi,

I have the code below as

 
 
cat <filename> | tr '~' '\n' | sed '/^$/ d' | sed "s/*/|/g" > <filename>
awk -F\| -vt=`date +%m%d%y%H%M%S%s` '$1=="ST",$1=="SE"{if($1=="ST"){close(f);f="214_edifile_"t"" ++i} ; $1=$1; print>f}' OFS=\| <filename>
 

This script works fine if the input file is a smaller size. Actually it replaces some characters and extracts the records starting from ST to SE and writes that in a seperate file. But when trying input file of bigger size the script is giving only partial output.

Can you tell me what could be the reason, is there any size limit of input file in UNIX OS please suggest to resolve.