04-03-2020
Run it in debug mode:
either put set echo in the script (and unset echo to turn it off again).
Or run the script with csh -x scriptname
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi All,
There 2 files in the folder /temp/tst/
1.txt
2.txt
When I run the command
find /temp/tst \( -name "*.txt" \) -exec tar cf /temp/123.tar {} \;
it creates the tar file 123.tar with only one file in it and that is 2.txt.But if I use the command
find /temp/tst \( -name "*.txt"... (1 Reply)
Discussion started by: rony_daniel
1 Replies
2. Shell Programming and Scripting
so i have hundreds of files named history.20071112.tar
(history.YYYYMMDD.tar)
and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis
here is what i have so far:
for FILE in `cat dirlist`
do
tar xvf $FILE ./status_*
done
dirlist is a text... (4 Replies)
Discussion started by: kuliksco
4 Replies
3. UNIX for Advanced & Expert Users
Hi,
On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files.
a) /usr/users/oracle/bin
b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies
4. Shell Programming and Scripting
I am a new to Linux and try to write a script to join three multiple files.
For example, there are three files
file1
# comment
a Kevin
b Vin
c Sam
file 2
# comment
a 10
b 20
c 40
file 3
# comment
a blue
b yellow (7 Replies)
Discussion started by: bonosungho
7 Replies
5. Shell Programming and Scripting
Hi Guru's,
I have to write a shell script which groups file names based upon the certain matching string pattern, then creates the Tar file for that particular group of files and then zips the Tar file created for the respective group of files.
For example, In the given directory these files... (3 Replies)
Discussion started by: rahu_sg
3 Replies
6. Shell Programming and Scripting
Hi,
Can any one tell me if i can read two files in a shell script...
My actual requirement is to read the 1st text file and parse it to get the file code and use this file code to retrieve data from database and print the fetched data in the 2nd text file (I have parsed it and printed the... (2 Replies)
Discussion started by: funonnet
2 Replies
7. Shell Programming and Scripting
Hi All,
I am a beginner for shell programming. I have a requirement to ftp multiple files. Here are the details.
I have around thiry files in one directory, I want a shell script which selects 5 files at a time and does ftp them to another host . After the transfer for first files is... (0 Replies)
Discussion started by: srikanthn
0 Replies
8. Shell Programming and Scripting
Hi,
i use the below script to send a single file to remote server from linux.
ftp -nvi <<!EOF
open $Host_name
user $USER_ID $PWD
binary
mput $file_name
quit
!EOF (where i... (2 Replies)
Discussion started by: pradebban
2 Replies
9. Shell Programming and Scripting
Hi all,
I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies
10. Shell Programming and Scripting
Hey everyone! I made a shell script that would go through a file and replace any phrase or letter with another phrase or letter. Helps update variable names or values. The following code is this:
#!/bin/sh
Word1="$1"
Replace1="$2"
File1="$3"
arg=$( echo "$Word1" | sed 's:\:\\&:g' )... (3 Replies)
Discussion started by: rebmonk
3 Replies
ROUND(3) 1 ROUND(3)
round - Rounds a float
SYNOPSIS
float round (float $val, [int $precision], [int $mode = PHP_ROUND_HALF_UP])
DESCRIPTION
Returns the rounded value of $val to specified $precision (number of digits after the decimal point). $precision can also be negative or
zero (default).
Note
PHP doesn't handle strings like "12,300.2" correctly by default. See converting from strings.
PARAMETERS
o $val
- The value to round
o $precision
- The optional number of decimal digits to round to.
o $mode
- Use one of the following constants to specify the mode in which rounding occurs.
+--------------------+---------------------------------------------------+
| Constant | |
| | |
| | Description |
| | |
+--------------------+---------------------------------------------------+
| | |
| PHP_ROUND_HALF_UP | |
| | |
| | Round $val up to $precision decimal places away |
| | from zero, when it is half way there. Making 1.5 |
| | into 2 and -1.5 into -2. |
| | |
| | |
|PHP_ROUND_HALF_DOWN | |
| | |
| | Round $val down to $precision decimal places |
| | towards zero, when it is half way there. Making |
| | 1.5 into 1 and -1.5 into -1. |
| | |
| | |
|PHP_ROUND_HALF_EVEN | |
| | |
| | Round $val to $precision decimal places towards |
| | the next even value. |
| | |
| | |
|PHP_ROUND_HALF_ODD | |
| | |
| | Round $val to $precision decimal places towards |
| | the next odd value. |
| | |
+--------------------+---------------------------------------------------+
RETURN VALUES
The rounded value
EXAMPLES
Example #1
round(3) examples
<?php
echo round(3.4); // 3
echo round(3.5); // 4
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2); // 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2); // 5.05
echo round(5.055, 2); // 5.06
?>
Example #2
$mode examples
<?php
echo round(9.5, 0, PHP_ROUND_HALF_UP); // 10
echo round(9.5, 0, PHP_ROUND_HALF_DOWN); // 9
echo round(9.5, 0, PHP_ROUND_HALF_EVEN); // 10
echo round(9.5, 0, PHP_ROUND_HALF_ODD); // 9
echo round(8.5, 0, PHP_ROUND_HALF_UP); // 9
echo round(8.5, 0, PHP_ROUND_HALF_DOWN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_EVEN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_ODD); // 9
?>
Example #3
$mode with precision examples
<?php
/* Using PHP_ROUND_HALF_UP with 1 decimal digit precision */
echo round( 1.55, 1, PHP_ROUND_HALF_UP); // 1.6
echo round( 1.54, 1, PHP_ROUND_HALF_UP); // 1.5
echo round(-1.55, 1, PHP_ROUND_HALF_UP); // -1.6
echo round(-1.54, 1, PHP_ROUND_HALF_UP); // -1.5
/* Using PHP_ROUND_HALF_DOWN with 1 decimal digit precision */
echo round( 1.55, 1, PHP_ROUND_HALF_DOWN); // 1.5
echo round( 1.54, 1, PHP_ROUND_HALF_DOWN); // 1.5
echo round(-1.55, 1, PHP_ROUND_HALF_DOWN); // -1.5
echo round(-1.54, 1, PHP_ROUND_HALF_DOWN); // -1.5
/* Using PHP_ROUND_HALF_EVEN with 1 decimal digit precision */
echo round( 1.55, 1, PHP_ROUND_HALF_EVEN); // 1.6
echo round( 1.54, 1, PHP_ROUND_HALF_EVEN); // 1.5
echo round(-1.55, 1, PHP_ROUND_HALF_EVEN); // -1.6
echo round(-1.54, 1, PHP_ROUND_HALF_EVEN); // -1.5
/* Using PHP_ROUND_HALF_ODD with 1 decimal digit precision */
echo round( 1.55, 1, PHP_ROUND_HALF_ODD); // 1.5
echo round( 1.54, 1, PHP_ROUND_HALF_ODD); // 1.5
echo round(-1.55, 1, PHP_ROUND_HALF_ODD); // -1.5
echo round(-1.54, 1, PHP_ROUND_HALF_ODD); // -1.5
?>
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | The $mode parameter was introduced. |
| | |
| 5.2.7 | |
| | |
| | The inner workings of round(3) was changed to |
| | conform to the C99 standard. |
| | |
+--------+---------------------------------------------------+
SEE ALSO
ceil(3), floor(3), number_format(3).
PHP Documentation Group ROUND(3)