09-08-2014
Quote:
Originally Posted by
junior-helper
I guess you mean
echo "${var%.*}" and
echo "${var%%.*}"
Yes, you are right! How on earth i could mix that up so consistently.... *shakes head about himself*
bakunin
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I want to save the contents of a variable to a file. How can that be achieved?
I have tried with:
echo $varname > textfile.txt
but for some reason it does not print anything. (1 Reply)
Discussion started by: carl_vieyra
1 Replies
2. Shell Programming and Scripting
Hi all,
I am displaying my result in HTML format using tables.
I want to save the results in file in the same format along with the table only.
How do i do that in perl?
I have attached the table structure .
I want to save like that itself .
with regards (2 Replies)
Discussion started by: vanitham
2 Replies
3. Shell Programming and Scripting
Hi,
I'am using "time" to check execution time of some script. Is there any possibility to save time command result into a file ? (2 Replies)
Discussion started by: Physix
2 Replies
4. Shell Programming and Scripting
Does anybody know any alternative way to save output result of a program into another new file?
I got try the command below:
program_used input_file > new_output_file
program_used input_file >> new_output_file
Unfortunately, both the ">" and ">>" is not work at this case to save the output... (6 Replies)
Discussion started by: patrick87
6 Replies
5. Shell Programming and Scripting
Hi,
I have a 3rd party tool on Solaris 8. I am running it thorugh my script but I am not able to capture its output into a variable.
Like, I tried, but did not work.
output=`/usr/bin/myTool`
echo $output
Also, I tried saving in a file but when I run, output is always shown on the... (19 Replies)
Discussion started by: angshuman_ag
19 Replies
6. Shell Programming and Scripting
Hi,
in shell script, i have the command swstart -p which returns an output. i want to store the output of this command into a variable. how i can do that
excerpt from the script
#!/usr/bin/ksh
#
#
#
# Program: swstart -p
#
# Description: Starts the sentinels on Slave server
... (4 Replies)
Discussion started by: lookinginfo
4 Replies
7. Shell Programming and Scripting
Hi,
If I type:
ls -l *txt | awk '{print $8}'
I get the file listing if I am in the directory.
If I try to do the same from a job flow, doing also other things, I can't do
ls -l directory/*txt | awk '{print $8}' > directory/result.txt
or
echo ls -l directory/*txt | awk '{print... (8 Replies)
Discussion started by: essemario
8 Replies
8. UNIX for Dummies Questions & Answers
i want to save the output of /scripts/whoowns domain.com to a username
like $user = /scripts/whoowns domain.com
but I'm not sure how to do that
This is inside a bash script
how can I get the output of /scripts/whoowns
then save that to a variable?
thanks!
---------- Post updated at... (0 Replies)
Discussion started by: vanessafan99
0 Replies
9. Shell Programming and Scripting
Currently I have a perl code to combine two different files.
#! /usr/bin/perl -w
use strict;
open FP1,"A.txt";
open FP2,"B.txt";
my ($l1,$l2);
while(1)
{
$l1=<FP1>; chomp $l1;
$l2=<FP2>; chomp $l2;
last unless(defined $l1 or defined $l2);
print "$l1 $l2\n";
}
close FP2;... (4 Replies)
Discussion started by: Tzeronone
4 Replies
10. UNIX for Advanced & Expert Users
My requirement is to read a column data from a file & save it in a variable for each row & process it. I am using the below code-
Leadlines="$TGTFILE/Error.txt">>$log_file
while read line
do
id = ` echo $line | cut -d "," -f1 `
email = ` echo $line | cut -d "," -f2 `
-----------
done
My... (2 Replies)
Discussion started by: saga20
2 Replies
INTVAL(3) 1 INTVAL(3)
intval - Get the integer value of a variable
SYNOPSIS
int intval (mixed $var, [int $base = 10])
DESCRIPTION
Returns the integer value of $var, using the specified $base for the conversion (the default is base 10). intval(3) should not be used on
objects, as doing so will emit an E_NOTICE level error and return 1.
PARAMETERS
o $var
- The scalar value being converted to an integer
o $base
- The base for the conversion
Note
If $base is 0, the base used is determined by the format of $var:
o if string includes a "0x" (or "0X") prefix, the base is taken as 16 (hex); otherwise,
o if string starts with "0", the base is taken as 8 (octal); otherwise,
o the base is taken as 10 (decimal).
RETURN VALUES
The integer value of $var on success, or 0 on failure. Empty arrays return 0, non-empty arrays return 1.
The maximum value depends on the system. 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647. So for example
on such a system, intval('1000000000000') will return 2147483647. The maximum signed integer value for 64 bit systems is
9223372036854775807.
Strings will most likely return 0 although this depends on the leftmost characters of the string. The common rules of integer casting
apply.
EXAMPLES
Example #1
intval(3) examples
The following examples are based on a 32 bit system.
<?php
echo intval(42); // 42
echo intval(4.2); // 4
echo intval('42'); // 42
echo intval('+42'); // 42
echo intval('-42'); // -42
echo intval(042); // 34
echo intval('042'); // 42
echo intval(1e10); // 1410065408
echo intval('1e10'); // 1
echo intval(0x1A); // 26
echo intval(42000000); // 42000000
echo intval(420000000000000000000); // 0
echo intval('420000000000000000000'); // 2147483647
echo intval(42, 8); // 42
echo intval('42', 8); // 34
echo intval(array()); // 0
echo intval(array('foo', 'bar')); // 1
?>
NOTES
Note
The $base parameter has no effect unless the $var parameter is a string.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.1.0 | |
| | |
| | Throws E_NOTICE and returns 1, when an object is |
| | passed to $var. |
| | |
+--------+---------------------------------------------------+
SEE ALSO
boolval(3), floatval(3), strval(3), settype(3), is_numeric(3), Type juggling, BCMath Arbitrary Precision Mathematics Functions.
PHP Documentation Group INTVAL(3)