|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Date capture & filter
Dear All, I am capturing system date and creating the file by using that time stamp, file is getting appended with checks of application & database check logs. But when the date is in between 1 to 9 both inclusive, it appends a single space to file name but after 9th it works fine. Code:
tmstmp=`date +%e%b%Y_%H%M%S`
file_name=Daily_Check"_"${tmstmp}.outOutput for the same is below: Daily_Check_ 7Jan2013_124706.out Daily_Check_26Jan2013_070036.out Desired output is below: Daily_Check_7Jan2013_124706.out Daily_Check_26Jan2013_070036.out Request you to help for the same. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
tmstmp=`date +%e%b%Y_%H%M%S`
tmstmp=${tmstmp# }
file_name=Daily_Check"_"${tmstmp}.out |
| The Following User Says Thank You to balajesuri For This Useful Post: | ||
pradeep84in (01-31-2013) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Use
%d instead of
%e to get the day zero-padded, or use
%-e to rule out padding (may be misleading: Code:
$ date +%-e%-m%Y -dtomorrow 122013 ). |
| The Following User Says Thank You to RudiC For This Useful Post: | ||
pradeep84in (01-31-2013) | ||
|
#4
|
|||
|
|||
|
Thanks your code works absolutely fine, can you explain what had happened here and how it had removed the blank space from the in between....
|
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Refer string manipulation
|
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Quote:
Thanks RudiC, I had used Code:
%d and it's giving the output by padding zero to it and it's keeping the lenght of the file name constant. I tried to use Code:
%-e but it's not giving the desired output. |
| 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 |
| PHPMaker 9 Help with Server Events & Filter | vestport | Web Programming | 0 | 05-17-2012 01:27 AM |
| Need to capture dates between start date and end date Using perl. | Nagaraja Akkiva | Shell Programming and Scripting | 6 | 07-21-2011 12:11 PM |
| Need to capture all dates between start date and End date. | Nagaraja Akkiva | Shell Programming and Scripting | 5 | 05-16-2011 11:48 AM |
| filter input & outputs to another file | user_prady | Shell Programming and Scripting | 1 | 11-05-2008 02:31 AM |
| Filter by modify date. | millerdc | Shell Programming and Scripting | 2 | 07-29-2007 09:48 PM |
|
|