Hi everyone, I’m not a deep shell script connoisseur, I know the basics and I’m open to suggestions for my problem,
I need to put together a script that runs 24 hours a day, but honestly I don’t even know where to start,
any idea how to assemble this script according to the case below?
I have the following scenario, EXAMPLE 1 (this is how it is today) and EXAMPLE 2 (expected result)
EXAMPLE 1
#Price_Notification_ProductABC
Price: 0.006813
change: +1.6%
Count Number: 1
#Price_Notification_ProductABC
Price: 0.006969
change: +2.3%
Count Number: 2
#Price_Notification_ProductABC
Price: 0.007060
change: +1.3%
Count Number: 3
#Price_Notification_ProductABC
Price: 0.007300
change: +3.4%
Count Number: 4
#Price_Notification_ProductABC
Price: 0.007453
change: +2.1%
Count Number: 5
EXAMPLE 2
#Price_Notification_ProductABC
Price: 0.006813
change: +1.6%
Count Number: 1
#Price_Notification_ProductABC
Price: 0.006969
change: +3.9%
Count Number: 2
#Price_Notification_ProductABC
Price: 0.007060
change: +5.2%
Count Number: 3
#Price_Notification_ProductABC
Price: 0.007300
change: +8.6%
Count Number: 4
#Price_Notification_ProductABC
Price: 0.007453
change: +10.7%
Count Number: 5
Requirements:
1- The item #Price_Notification_ProductABC is not a fixed item, the search can return several products
(Price_Notification_ProductABC, #Price_Notification_ProductXYZ, #Price_Notification_Product123, etc)
so, for this to work correctly, I believe it is necessary to have some match using grep
2- The Price item does not have pre-defined decimal places, it can be in the format Price: 0.006813 Price: 1.256 Price: 524.354, etc, it is something dynamic
3- The change item is the most complex to explain, the notifications return with the percentage containing numbers always fractional as in EXAMPLE 1,
- I would like to have a filter that does the sum of the calculation incrementally as in EXAMPLE 2
- this incremental sum must always add the percentage of the previous notification + the percentage of the current notification
- but it is necessary to have some conditions for this:
The Price item of the current notification must always have a value greater than that of the previous notification, if this condition is not met,
the cycle/filter containing the sum/percentage of notifications must be reset, thus starting a new cycle for subsequent notifications
4- The Count Number item, I don’t really know how to handle this item, as the Count Number is also dynamic and is always reset to 0 every hour, but I’m open to suggestions on how to handle this item
Note, I get this information that way, there’s not much I can do about it, I’m trying to build a script that serves me according to the information received.
Thanks!