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.
tmstmp=`date +%e%b%Y_%H%M%S`
file_name=Daily_Check"_"${tmstmp}.out
Output 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.
tmstmp=`date +%e%b%Y_%H%M%S`
tmstmp=${tmstmp# }
file_name=Daily_Check"_"${tmstmp}.out
1 Like
RudiC
3
Use %d
instead of %e
to get the day zero-padded, or use %-e
to rule out padding (may be misleading:
$ date +%-e%-m%Y -dtomorrow
122013
).
1 Like
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....
Yoda
5
Refer string manipulation (link removed)
Thanks RudiC, I had used
%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
%-e
but it's not giving the desired output.