Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Splitting week start date and end date based on custom period start dates Post 303043750 by nani2019 on Wednesday 5th of February 2020 11:04:48 AM
Old 02-05-2020
Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below.

Could you please help out to achieve solution through shell script..

Code:
 File content:

period_start_date	period_end_date	period_code
2020-01-01	2020-01-15	P1
2020-01-05	2020-01-19	P2
2020-01-16	2020-01-31	P1
2020-01-20	2020-02-04	P2
2020-02-01	2020-02-15	P1
2020-02-05	2020-02-19	P2
2020-02-16	2020-02-29	P1
2020-02-20	2020-03-04	P2
2020-03-01	2020-03-15	P1
2020-03-05	2020-03-19	P2
2020-03-16	2020-03-31	P1
2020-03-20	2020-04-04	P2
2020-04-01	2020-04-15	P1
2020-04-05	2020-04-19	P2
2020-04-16	2020-04-30	P1
2020-04-20	2020-05-04	P2
2020-05-01	2020-05-15	P1
2020-05-05	2020-05-19	P2
2020-05-16	2020-05-31	P1
2020-05-20	2020-06-04	P2

Code:
Expected Result for  					
1) period start date 	2020-01-01	Period End date	2020-01-15	Period code 	 P1        
2) period start date 	2020-01-05	Period End date	2020-01-19	Period code 	 P2     
3) period start date 	2020-01-16	Period End date	2020-01-31	Period code 	 P1     
4) period start date 	2020-01-20	Period End date	2020-02-04	Period code 	 P2

Code:
week Start Date	Week End Date	Period strat Date	Period end Date	Period code
2020-01-01	2020-01-05	2020-01-01	2020-01-15	P1
2020-01-06	2020-01-12	2020-01-01	2020-01-15	P1
2020-01-13	2020-01-15	2020-01-01	2020-01-15	P1
2020-01-05	2020-01-05	2020-01-05	2020-01-19	P2
2020-01-06	2020-01-12	2020-01-05	2020-01-19	P2
2020-01-13	2020-01-19	2020-01-05	2020-01-19	P2
2020-01-16	2020-01-19	2020-01-16	2020-01-31	P1
2020-01-20	2020-01-26	2020-01-16	2020-01-31	P1
2020-01-27	2020-01-31	2020-01-16	2020-01-31	P1
2020-01-20	2020-01-26	2020-01-20	2020-02-04	P2
2020-01-27	2020-02-02	2020-01-20	2020-02-04	P2
2020-02-03	2020-02-04	2020-01-20	2020-02-04	P2


Last edited by nani2019; 02-05-2020 at 12:05 PM.. Reason: none
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare Start date and End date...

Hi All, I have problem in my file. It has two date variable. There are 2 variables which has the values as below 1. START_MONTH = “Date(YYYYMM) format” Ex: 201008 2. END_MONTH = “Date(YYYYMM) format” Ex: 201105 The end date should be greater than start date. Now we... (3 Replies)
Discussion started by: suresh01_apk
3 Replies

2. 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

3. 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

4. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

5. Shell Programming and Scripting

Getting the Start, End time and duration using date command

Oracle Enterprise Linux We want to track how long a process takes to complete its execution. This is what we want in the schell script Before the process is started , get the time with date, hours and minutes execute the process After the process has ended , get the time with date,... (5 Replies)
Discussion started by: omega3
5 Replies

6. Shell Programming and Scripting

Get the lines from logfile within start and end date

Hi guys, I am having the below logfile,date in yyyy-mm-dd 2013-08-02 *some content* 2013-08-02 *some content* 2013-08-02 *some content* 2013-08-03 *some content* 2013-08-05 *some content* from the above logfile i need to get the lines between the two timestamps,if i give... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

7. UNIX for Dummies Questions & Answers

Print start date to end date, given $1 & $2 in ksh

Dear all, I have an user passing 2 parameter 31/03/2015 and 02/04/2015 to a ksh script. How to print the start date to end date. Expected output is : 31/03/2015 01/04/2015 02/04/2015 Note : 1. Im using aix and ksh 2. I have tried to convert the given input into a date, didnt... (0 Replies)
Discussion started by: mr.rajaravi
0 Replies
ippool(4)							   File Formats 							 ippool(4)

NAME
ippool, ippool.conf - IP pool file format SYNOPSIS
ippool.conf DESCRIPTION
The format for files accepted by ippool(1M) is described by the following grammar: line ::= table | groupmap . table ::= "table" role tabletype . groupmap ::= "group-map" inout role number ipfgroup tabletype ::= ipftree | ipfhash . role ::= "role" "=" "ipf" . inout ::= "in" | "out" . ipftree ::= "type" "=" "tree" number "{" addrlist "}" . ipfhash ::= "type" "=" "hash" number hashopts "{" hashlist "}" . ipfgroup ::= setgroup hashopts "{" grouplist "}" | hashopts "{" setgrouplist "}" . setgroup ::= "group" "=" groupname . hashopts ::= size [ seed ] | seed . size ::= "size" "=" number . seed ::= "seed" "=" number . addrlist ::= range [ "," addrlist ] . grouplist ::= groupentry [ ";" grouplist ] | groupentry ";" | addrmask ";" | addrmask ";" [ grouplist ] . setgrouplist ::= groupentry ";" [ setgrouplist ] . groupentry ::= addrmask "," setgroup . range ::= addrmask | "!" addrmask . hashlist ::= hashentry ";" [ hashlist ] . hashentry ::= addrmask . addrmask ::= ipaddr | ipaddr "/" mask . mask ::= number | ipaddr . groupname ::= number | name . number ::= digit { digit } . ipaddr = host-num "." host-num "." host-num "." host-num . host-num = digit [ digit [ digit ] ] . digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" . name ::= letter { letter | digit } . The IP pool configuration file is used for defining a single object that contains a reference to multiple IP address/netmask pairs. A pool can consist of a mixture of netmask sizes, from 0 to 32. In the current release, only IPv4 addressing is supported in IP pools. The IP pool configuration file provides for defining two different mechanisms for improving speed in matching IP addresses with rules. The first, table, defines a lookup table to provide a single reference in a filter rule to multiple targets. The second mechanism, group-map, provides a mechanism to target multiple groups from a single filter line. The group-map command can be used only with filter rules that use the call command to invoke either fr_srcgrpmap or fr_dstgrpmap, to use the source or destination address, respectively, for determining which filter group to jump to next for continuation of filter packet pro- cessing. Pool Types Two storage formats are provided: hash tables and tree structure. The hash table is intended for use with objects that all contain the same netmask or a few, different sized-netmasks of non-overlapping address space. The tree is designed for supporting exceptions to a covering mask, in addition to normal searching as you would do with a table. It is not possible to use the tree data storage type with group-map configuration entries. Pool Roles When a pool is defined in the configuration file, it must have an associated role. At present the only supported role is ipf. Future devel- opment might see further expansion of the use of roles by other sections of IPFilter code. EXAMPLES
The following examples show how the pool configuration file is used with the ipf configuration file to enhance the succinctness of the lat- ter file's entries. Example 1: Referencing Specific Pool The following example shows how a filter rule makes reference to a specific pool for matching of the source address. pass in from pool/100 to any The following pool configuration matches IP addresses 1.1.1.1 and any in 2.2.0.0/16, except for those in 2.2.2.0/24. table role = ipf type = tree number = 100 { 1.1.1.1/32, 2.2.0.0/16, !2.2.2.0/24 }; Example 2: ipf Configuration Entry The following ipf.conf excerpt uses the fr_srcgrpmap/fr_dstgrpmap lookups to use the group-map facility to look up the next group to use for filter processing, providing the call filter rule is matched. call now fr_srcgrpmap/1010 in all call now fr_dstgrpmap/2010 out all pass in all group 1020 block in all group 1030 pass out all group 2020 block out all group 2040 An ippool configuration to work with the preceding ipf.conf segment might look like the following: group-map in role = ipf number = 1010 { 1.1.1.1/32, group = 1020; 3.3.0.0/16, group = 1030; }; group-map out role = ipf number = 2010 group = 2020 { 2.2.2.2/32; 4.4.0.0/16; 5.0.0.0/8, group = 2040; }; FILES
o /dev/ippool o /etc/ipf/ippool.conf o /etc/hosts ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWipfu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
ipf(1M), ipnat(1M), ippool(1M), ipf(4), attributes(5), hosts(4) SunOS 5.10 30 Apr 2004 ippool(4)
All times are GMT -4. The time now is 03:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy