|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
[Solved] Adding time stamp to file name
I have the awk Code:
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"
Last edited by vbe; 07-05-2012 at 07:15 AM.. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
What format should the timestamp follow?
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Code:
TIMESTAMP=$( date +%m%d%y.%H%M%S )
FILE="${FILE}.${TIMESTAMP}" |
|
#4
|
|||
|
|||
|
I want the time format as Code:
date +%m%d%y%H%M%S. I tried the suggested way, but when doing it I got the files generated as Code:
${FILE}.${TIMESTAMP}3
${FILE}.${TIMESTAMP}2
${FILE}.${TIMESTAMP}1Last edited by vbe; 07-05-2012 at 10:37 AM.. Reason: code tags please! |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Try: Code:
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> |
| The Following User Says Thank You to bartus11 For This Useful Post: | ||
atlantis_yy (07-05-2012) | ||
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Wonderful, It worked !!!
Thanks a ton. |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Hi, I have the code below as Code:
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. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| file time stamp | rajesh_pola | Shell Programming and Scripting | 4 | 10-14-2011 06:43 AM |
| Set date and time stamp of one file to another | prvnrk | Shell Programming and Scripting | 2 | 12-31-2010 08:57 AM |
| Change time stamp of a file | apskaushik | Shell Programming and Scripting | 3 | 10-25-2010 01:12 PM |
| change the time stamp of file | anish19 | Shell Programming and Scripting | 2 | 07-01-2008 06:51 AM |
| how do i put a time stamp in a file name | jhamm | Shell Programming and Scripting | 5 | 01-29-2007 09:00 AM |
|
|