I wanna use a system function to deal with several data. So I use awk variable FILENAME to transfer the file directory to system command, but it does not work.
I use a shell function "out_function" to deal with data and save the result in another directory with the same file name.
How can I... (2 Replies)
Hi
I want to pass variables with the NR function in awk command.
test_file1 is input file having 500 records.
var1=100.
var2=200
awk -F" " 'NR >= $var1 && NR <= $var2' test_file1 > test_file2.
My end result should be that test_file2 should have records from line number between... (2 Replies)
I am trying to pass max as a sommand line argument when I call awk.
Made the modification in the BEGIN but it is not working
I'm getting an error as below:
awk: txsrx.awk:82: (FILENAME=jcd.tx FNR=4161) fatal: cannot open file `40' for reading (No such file or directory)
Somehow it... (2 Replies)
Thanks in advance : )
I try for a long time searching for a way to split a large gzip csv file into many gzip files (except for the last sub-file which is to joint the next big file's children.) All the subfiles are to be named by the field.
But I only managed to split them into the... (9 Replies)
I need to pass values at runtime for the below awk command where
l is the length and partial.txt is the file name.
awk -v l=285 '{s="%-"l"s\n";printf(s,$0);}' partial.txt > temp1.txt; (5 Replies)
Hello,
I'm having some issues getting a home dir from a remote server passed to a variable.
Here is what I have so far:
rsh server "(ls -ld /home*/user | awk '{print \$9}')"
/home3/userThat works fine and brings back what I need.
But when I try to add it to a variable it goes all... (3 Replies)
Hi,
I am facing one issue. The awk command works fine if i hardcode the file name but if is pass it as an arguement it doesn't work. For e.g:Below commands works fine
awk -v A="$type" '{F=substr($0,23,8) "_LTD_" A ".txt"; print $0 >> F; close(F) }' RL004.txt
But the below command does not... (2 Replies)
#!/bin/awk -f
BEGIN {
FS=":";
}
{
if ( $7 == "" ) {
print $1 ": no password!";
}
}
I want to execute this program for a particular user to check for his password from the file /etc/passwd (as the input file) and the user details to be given... (1 Reply)
I am able to execute awk command from shell prompt. but the same command is not getting executed when written and run in a bash script
the command from bash cmd prompt.
awk '/world/{for (i=2; i<NF; i++) printf $i " "; print $NF}1' myfile >tmp$$ ; mv tmp$$ myfile
file:
# hello world my... (4 Replies)
My file (the output of an experiment) starts off looking like this,
_____________________________________________________________
Subjects incorporated to date: 001
Data file started on machine PKSHS260-05CP
**********************************************************************
Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
LEARN ABOUT PHP
datetime.add
DATETIME.ADD(3) 1 DATETIME.ADD(3)DateTime::add - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object
Object oriented style
SYNOPSIS
public DateTime DateTime::add (DateInterval $interval)
DESCRIPTION
Procedural style
DateTime date_add (DateTime $object, DateInterval $interval)
Adds the specified DateInterval object to 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.add(3) example
Object oriented style
<?php
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P10D'));
echo $date->format('Y-m-d') . "
";
?>
Procedural style
<?php
$date = date_create('2000-01-01');
date_add($date, date_interval_create_from_date_string('10 days'));
echo date_format($date, 'Y-m-d');
?>
The above examples will output:
2000-01-11
Example #2
Further DateTime.add(3) examples
<?php
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('PT10H30S'));
echo $date->format('Y-m-d H:i:s') . "
";
$date = new DateTime('2000-01-01');
$date->add(new DateInterval('P7Y5M4DT4H3M2S'));
echo $date->format('Y-m-d H:i:s') . "
";
?>
The above example will output:
2000-01-01 10:00:30
2007-06-05 04:03:02
Example #3
Beware when adding months
<?php
$date = new DateTime('2000-12-31');
$interval = new DateInterval('P1M');
$date->add($interval);
echo $date->format('Y-m-d') . "
";
$date->add($interval);
echo $date->format('Y-m-d') . "
";
?>
The above example will output:
2001-01-31
2001-03-03
NOTES DateTime.modify(3) is an alternative when using PHP 5.2.
SEE ALSO DateTime.sub(3), DateTime.diff(3), DateTime.modify(3).
PHP Documentation Group DATETIME.ADD(3)