Hi all,
I am parsing command line options using getopts.
The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument.
Below is the script:
while getopts :hd:t:s:l:p:f: opt
do
case "$opt" in
-h|-\?)... (2 Replies)
Hi,
So my script reads $1 on the command line.
example:
SCRIPT_NAME 1111
In my script I use a nawk statement to grab $1 but I also need it to read $1 from the variable (1111 from command line in the example)
nawk -F, '($1~1111)' *.$date.*
What can I do so that this nawk statement... (2 Replies)
Hi All,
I need help from you guys.
In the shell script I have, I have a variable that has a value as follows
a=abc_20100614_12346
I want to do the following logic,
if a like '%20100614%' then
true
else
false
fi
Guys please help me out on this.
I tried the follwoing option
... (9 Replies)
To find all the files in your home directory that have been edited in some way since the last tar file, use this command:
find . -newer backup.tar.gz
Is anyone familiar with an older solution?
looking to identify files older then 15mins across several directories.
thanks,
manny (2 Replies)
Hi,
I need some help with an issue on my script. When I run option 3 it works just fine.
When I run Option 4 which puts back the changes done in option 3 it fails. Oddly enough when I run Option 4 right after it failed it seems to work. I am not sure why that is or is a false positive.
In... (2 Replies)
could someone show me a sample command line option driven script?
i want to see an easy way to write one and how i can execute it using command line options such as typing in
read.pl -i <id> -c <cmds> -s <start> -e <end>
would read out all the commands run by ID . from start time to... (7 Replies)
Hi,
Some one help in completing the script:
I need to write a script which has to select automatically only one option(below case only D - ALL) out of all options instead of manual entry
There is an script which is used to test number of connection to different db that it connects when we... (7 Replies)
Hi,
I am trying to create warraper script to run a shell script in which can be run using particular user id only .
I have deoded the user password thst user and wanted to pass while running inside shell script as below .Script should come back to same shell after executing screen_update.sh.... (2 Replies)
HI Guys,
My Script abc.sh
1) Checks
2) CA Scipt
3) CIA Script
0) Exit
Enter Choice :
Now if i select choice 2 then after finshed choice 2 wait for 40 min and run choice 3
what i can write in CA Scipt option:
if
then
My Code :
... (3 Replies)
Hello,
I want to design a script that will call an existing menu script and select options one by one and redirict the out put to a file.
For example;-
In the script MENU.sh there are 10 options i want to design a script MENU2.sh that will select option 2 3 4 6 7 10 and redirict the output... (4 Replies)
Discussion started by: spradha
4 Replies
LEARN ABOUT PHP
datetime.sub
DATETIME.SUB(3) 1 DATETIME.SUB(3)DateTime::sub - Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
Object oriented style
SYNOPSIS
public DateTime DateTime::sub (DateInterval $interval)
DESCRIPTION
Procedural style
DateTime date_sub (DateTime $object, DateInterval $interval)
Subtracts the specified DateInterval object from the specified DateTime object.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $interval
- A DateInterval object
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
EXAMPLES
Example #1
DateTime.sub(3) example
Object oriented style
<?php
$date = new DateTime('2000-01-20');
$date->sub(new DateInterval('P10D'));
echo $date->format('Y-m-d') . "
";
?>
Procedural style
<?php
$date = date_create('2000-01-20');
date_sub($date, date_interval_create_from_date_string('10 days'));
echo date_format($date, 'Y-m-d');
?>
The above examples will output:
2000-01-10
Example #2
Further DateTime.sub(3) examples
<?php
$date = new DateTime('2000-01-20');
$date->sub(new DateInterval('PT10H30S'));
echo $date->format('Y-m-d H:i:s') . "
";
$date = new DateTime('2000-01-20');
$date->sub(new DateInterval('P7Y5M4DT4H3M2S'));
echo $date->format('Y-m-d H:i:s') . "
";
?>
The above example will output:
2000-01-19 13:59:30
1992-08-15 19:56:58
Example #3
Beware when subtracting months
<?php
$date = new DateTime('2001-04-30');
$interval = new DateInterval('P1M');
$date->sub($interval);
echo $date->format('Y-m-d') . "
";
$date->sub($interval);
echo $date->format('Y-m-d') . "
";
?>
The above example will output:
2001-03-30
2001-03-02
NOTES DateTime.modify(3) is an alternative when using PHP 5.2.
SEE ALSO DateTime.add(3), DateTime.diff(3), DateTime.modify(3).
PHP Documentation Group DATETIME.SUB(3)