Context:
I am using sed in a cronjob to change the dates in a separate sql script every week. Each week the dates must be updated to reflect the Monday and Friday of the previous week. I have solved the problem but in solving it I discovered a major weakness in my knowledge of sed.
Lines to be changed ( SQL excerpt ): My current solution: My question ( 2 parts ):
1. How would you simplify this or improve this?
2. Regarding Fridays: How would you express the following in sed?:
Find all lines starting with "datediff" AND NOT ending with "and"
THEN
Replace the 2nd date string with the variable for last friday.
Here's what I've tried ~
Keeps saying "Event not found".
Thanks!
Bub
UPDATE: I figured out one possible solution. Maybe not the most elegant ...thoughts? ~
Note for noobs: Those are side-by-side single quotes NOT double quotes in the example above.
Please Help... I am trying to manipulte the following line
Before :
<user:Account_Password>002786</user:Account_Password>
the password is the "variable", i need to delete / omit the password in the file, (it occurs several thousand times)
so the tag line looks like
After:... (4 Replies)
hi,
I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses...
Here is the configuration of my system:
* an IBM P550 machine,
* an AIX 5.3 running on it and
* an oracle database, already installed on it.
The problem (or... (1 Reply)
I guess it was getting a little messy on the other post so here goes:
Link to previous post for Question:
https://www.unix.com/shell-programming-scripting/111338-awk-replace-particular-field.html
Continuation of Question
hey i was messing around a bit ... made me wonder...
If the... (1 Reply)
Hi Guys,
Req your help in searching and replacing the word that comes after equals(=) symbol
I would like to replace the sting in bold with a string in variable.
d=ABCDF8C44C22
# grep -i NIM_MASTERID ${_NIMINFO}
export NIM_MASTERID=00CDF8C44C00
I'm looking to replace any word that... (4 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Hi, everyone.
I need to write a program to get io info based on libperfstat.
But the "write time" of a disk is just half of the value get from iostat.
I'm confused and can't explain. Help please.
How I calculate "write service time per sec":
In iostat:
write service... (0 Replies)
I am trying to use the below sed command to replace all "|" to ^, in a folder had 50 dat files. when i tried with 1 file it worked but when i tried with wild card, is not working.
sed -i 's/"|"/\^/g' *.dat
Is this the proper way to use sed command thank you very much for help. (3 Replies)
I need to find two matches in the output from ps. I am searching with ps -ef |grep mysql for:
my.cnf
/bin/sh /usr/bin/mysqld_safe --defaults-file=/data/mysql/master/agis_core/etc/my.cnf
after this match I want to search back and match the hostname which is x number of lines back, above the... (2 Replies)
Discussion started by: bash_in_my_head
2 Replies
LEARN ABOUT DEBIAN
html::calendarmonth::datetool
HTML::CalendarMonth::DateTool(3pm) User Contributed Perl Documentation HTML::CalendarMonth::DateTool(3pm)NAME
HTML::CalendarMonth::DateTool - Base class for determining which date package to use for calendrical calculations.
SYNOPSIS
my $date_tool = HTML::CalendarMonth::DateTool->new(
year => $YYYY_year,
month => $one_thru_12_month,
weeknum => $weeknum_mode,
historic => $historic_mode,
datetool => $specific_datetool_if_desired,
);
DESCRIPTION
This module attempts to utilize the best date calculation package available on the current system. For most contemporary dates this usually
ends up being the internal Time::Local package of perl. For more exotic dates, or when week number of the years are desired, other methods
are attempted including DateTime, Date::Calc, Date::Manip, and the linux/unix 'ncal' or 'cal' commands. Each of these has a specific
subclass of this module offering the same utility methods needed by HTML::CalendarMonth.
METHODS
new()
Constructor. Takes the following parameters:
year
Year of calendar in question (required). If you are rendering exotic dates (i.e. dates outside of 1970 to 2038) then something
besides Time::Local will be used for calendrical calculations.
month
Month of calendar in question (required). 1 through 12.
weeknum
Optional. When specified, will limit class excursions to those that are currently set up for week of year calculations.
historic
Optional. If the the ncal or cal commands are available, use one of them rather than other available date modules since these
utilities accurately handle some specific historical artifacts such as the transition from Julian to Gregorian.
datetool
Optional. Mostly for debugging, this option can be used to indicate a specific HTML::CalendarMonth::DateTool subclass for
instantiation. The value can be either the actual utility class, e.g., Date::Calc, or the name of the CalendarMonth handler leaf
class, e.g. DateCalc. Use 'ncal' or 'cal', respectively, for the wrappers around those commands.
There are number of methods automatically available:
month()
year()
weeknum()
historical()
datetool()
Accessors for the parameters provided to "new()" above.
dow1st()
Returns the day of week number for the 1st of the "year" and "month" specified during the call to "new()". Relies on the presence of
"dow1st_and_lastday()". Should be 0..6 starting with Sun.
lastday()
Returns the last day of the month for the "year" and "month" specified during the call to "new()". Relies on the presence of
"dow1st_and_lastday()".
Overridden methods
Subclasses of this module must provide at least the "day_epoch()" and "dow1st_and_lastday()" methods.
dow1st_and_lastday()
Required. Provides a list containing the day of the week of the first day of the month (0..6 starting with Sun) along with the last day
of the month.
day_epoch()
Optional unless interested in epoch values for wacky dates. For a given day, and optionally "month" and "year" if they are different
from those specified in "new()", provide the unix epoch in seconds for that day at midnight.
If the subclass is expected to provide week of year numbers, three more methods are necessary:
dow()
For a given day, and optionally "month" and "year" if they are different from those specified in "new()", provide the day of week
number. (1=Sunday, 7=Saturday).
add_days($days, $delta, $day, [$month], [$year])
For a given day, and optionally "month" and "year" if they are different from those specified in "new()", provide a list of year,
month, and day once "delta" days have been added.
week_of_year($day, [$month], [$year])
For a given day, and optionally "month" and "year" if they are different from those specified in "new()", provide a list with the week
number of the year along with the year. (some days of a particular year can end up belonging to the prior or following years).
AUTHOR
Matthew P. Sisk, <sisk@mojotoad.com>
COPYRIGHT
Copyright (c) 2010 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
SEE ALSO HTML::CalendarMonth(3), Time::Local(3), DateTime(3), Date::Calc(3), Date::Manip(3), cal(1)perl v5.12.4 2011-08-26 HTML::CalendarMonth::DateTool(3pm)