Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant.
THX! (2 Replies)
#!/bin/bash
if then
#echo "infinite loop"
exit 0
fi
when I run this file I get the following error:
./test_infinite_loop: line 5: syntax error near unexpected token `fi'
./test_infinite_loop: line 5: `fi'
:confused: (4 Replies)
CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error.
source $CA_VERSION_DATA
if * ]
then
echo "CA_RELESE $CA_RELEASE is invalid"
exit -1
fi
+ source /etc/ncgl/ca_version_data
++ CA_PRODUCT_ID=samxts
++ CA_RELEASE=6
++ CA_WEEK_NO=7
++... (3 Replies)
Hi all,
How am I read a file, find the match regular expression and overwrite to the same files.
open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat";
open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat";
while (<DESTINATION_FILE>)
{
# print... (1 Reply)
Hello All,
I'm trying to extract the lines between two consecutive elements of an array from a file.
My array looks like:
problem_arr=(PRS111 PRS213 PRS234)
j=0
while } ]
do
k=`expr $j + 1`
sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt
---some operation goes... (11 Replies)
Hello All,
Not sure why this is happening...
When the following If Statement is evaluated for some reason it is creating a file in the CWD called '0'. I've seen this happen
before, just not in an If Statement...
CODE:
if
then
DIR_NAME="$1"
DIR_SIZE=0
STATUS=""
else... (3 Replies)
Discussion started by: mrm5102
3 Replies
LEARN ABOUT PHP
fprintf
FPRINTF(3) 1 FPRINTF(3)fprintf - Write a formatted string to a streamSYNOPSIS
int fprintf (resource $handle, string $format, [mixed $args], [mixed $...])
DESCRIPTION
Write a string produced according to $format to the stream resource specified by $handle.
PARAMETERS
o $handle
-A file system pointer resource that is typically created using fopen(3).
o $format
- See sprintf(3) for a description of $format.
o $args
-
o $...
-
RETURN VALUES
Returns the length of the string written.
EXAMPLES
Example #1
fprintf(3): zero-padded integers
<?php
if (!($fp = fopen('date.txt', 'w'))) {
return;
}
fprintf($fp, "%04d-%02d-%02d", $year, $month, $day);
// will write the formatted ISO date to date.txt
?>
Example #2
fprintf(3): formatting currency
<?php
if (!($fp = fopen('currency.txt', 'w'))) {
return;
}
$money1 = 68.75;
$money2 = 54.35;
$money = $money1 + $money2;
// echo $money will output "123.1";
$len = fprintf($fp, '%01.2f', $money);
// will write "123.10" to currency.txt
echo "wrote $len bytes to currency.txt";
// use the return value of fprintf to determine how many bytes we wrote
?>
SEE ALSO printf(3), sprintf(3), sscanf(3), fscanf(3), vsprintf(3), number_format(3).
PHP Documentation Group FPRINTF(3)