Date capture & filter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Date capture & filter
# 1  
Old 01-31-2013
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}.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.
# 2  
Old 01-31-2013
Code:
tmstmp=`date +%e%b%Y_%H%M%S`
tmstmp=${tmstmp# }
file_name=Daily_Check"_"${tmstmp}.out

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 01-31-2013
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

).
This User Gave Thanks to RudiC For This Post:
# 4  
Old 01-31-2013
Quote:
Originally Posted by balajesuri
Code:
tmstmp=`date +%e%b%Y_%H%M%S`
tmstmp=${tmstmp# }
file_name=Daily_Check"_"${tmstmp}.out

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....
# 5  
Old 01-31-2013
Refer string manipulation (link removed)
# 6  
Old 02-01-2013
Quote:
Originally Posted by RudiC
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

).

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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How-To Check & Filter user input

Hi, On my Java webpage which invokes the shell script has two checkboxes viz ... apache and weblogic apache require one parameter i.e apache home from the user while Weblogic requires three or five params from the user vi.z weblogic_home or <jdk_home, config_home & pid>, username and... (4 Replies)
Discussion started by: mohtashims
4 Replies

2. Shell Programming and Scripting

Script to filter by date

Hello, I currently have the need to perform backup, naming the file by date. How do I get the script, you can choose the most current file or current date and then upload it? My script is related to this topic that is already closed. Read Post Can anyone help me? (12 Replies)
Discussion started by: hdegenaro
12 Replies

3. Web Development

PHPMaker 9 Help with Server Events & Filter

Hello, I need some help with PHPMaker 9 "Server Events". trying to do a simple filter but my lack of knowledge of PHP & Mysql is getting me in a jam. I have 2 tables: MyMainTable = which has all individual records for different people and Users = the security table that also has... (0 Replies)
Discussion started by: vestport
0 Replies

4. Linux

awk filter & Auto gen Mail

hi experts 2012-01-30 10:30:01:812 "y" "NA" "30/01/2012 10:30:01:154 AM" 2012-01-30 10:33:46:342 "y" "NA" "30/01/2012 10:33:45:752 AM" 2012-01-30 10:41:11:148 "n" "200" "30/01/2012 10:41:10:558 AM" 2012-01-30 10:44:48:049 "y" "NA" ... (7 Replies)
Discussion started by: nith_anandan
7 Replies

5. Shell Programming and Scripting

Need to capture dates between start date and end date Using perl.

Hi All, Want to get all dates and Julian week number for that date between the start date and end date. How can I achive this using perl? (To achive above functionality, I was connecting to the database from DB server. Need to execute the same script in application server, since databse... (6 Replies)
Discussion started by: Nagaraja Akkiva
6 Replies

6. Shell Programming and Scripting

Need to capture all dates between start date and End date.

Hi All, I enter Start date and end date as parameters. I need to capture dates between start date and end date. Please let me know if you have any idea the same. Thanks in advance. Nagaraja Akkivalli. (5 Replies)
Discussion started by: Nagaraja Akkiva
5 Replies

7. Shell Programming and Scripting

Script to capture userids logged on & killing as well

Can someone help me with a script to capture the list of users logged on at a point of time, and if a particular user id say xyz exists, kill that process Id. (2 Replies)
Discussion started by: ggayathri
2 Replies

8. Shell Programming and Scripting

filter input & outputs to another file

Hello All, I am stuck with the follwing problem , pls give me some advice.. Input file: input clock; input reset; \\reset all input yuv; //input comment output sur; output sud; output vtua; output tur; input ebi; //output comment The input file... (1 Reply)
Discussion started by: user_prady
1 Replies

9. Shell Programming and Scripting

Filter by modify date.

I want to filter an "ls -al" command so it only shows me files with modify dates older than two weeks. What is the best way of doing this? (2 Replies)
Discussion started by: millerdc
2 Replies

10. UNIX for Dummies Questions & Answers

ftp by date filter

i would be grateful if someone could supply me with a shell script which performed a ftp but only retrieved files which had a created date greater than a specific date - is this possible with ftp? many thanks mc (1 Reply)
Discussion started by: campbem
1 Replies
Login or Register to Ask a Question