Comparing floating number and replace the smaller one with awk?
Hi guys,
I tried to write a script for replacing some number in a bunch of files. However, I failed because my limited bash scripting knowledge.
Here I will explain the expected function:
I have many data files need to be processed. Here shows one part of a file as an example: a list with floating numbers and the first line shows the total number (line 28) of the following floating numbers. The floating numbers are always start from line 29.
Function one: comparing each of these floating numbers with 0; if smaller than 0; just replace this negative number with its absolute value or simply by removing the negative sign; this with generate new file 1;
Function two: reading or setting a threshold value, for instance 10.0; compare each of these floating numbers including the original negative numbers with this threshold value 10.0; if smaller than 10.0; just replace this number with 10.0; this with generate new file 2;
Thank you very much for your kind efforts and for your time!
Zhen
Hi,
I am trying to write a script to extract multiple sets of data from a chemistry output file. The problem section is in the following format...
Geometry "geometry" -> "geometry"
1 Pd 46.0000 -0.19290971 0.00535260 0.02297606
2 P ... (7 Replies)
Hi,
I' using bash and I would like to use "bc" to compute the ratio of of two numbers and assign the ratio to a variable.
The numbers are in a file, e.g.
196.304492
615.348986
Any idea how to do it?
N.B. I cannot change the file to have 196.304492 / 615.348986 as the file is produced by... (14 Replies)
Hello,
I really would appreciate some help with a bash script for some string manipulation on an SQL dump:
I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump.
This is quite easy with sed:
sed -e... (1 Reply)
Hello folks
I Hope everyone is fine. I am calculating number of bytes calculation from apache web log.
awk '{ sum += $10 } END { print sum }' /var/httpd/log/mydomain.log
7.45557e+09
it show above number, what should i do it sow number like 7455, i mean if after decimal point above 5 it... (5 Replies)
Hi !
How to increment a varibale in ksh.
#!/bin/ksh
set -x
RELEASE_NUM=5.2.103
VAL=0.0.1
RELEASE_NUM=`echo $RELEASE_NUM + $VAL | bc`
echo $RELEASE_NUM
The above code is throwing this error.
+ RELEASE_NUM=5.2.103 (2 Replies)
Hi All,
I have a problem to find number of lines per column smaller than the values given in a different file. In example, compare the 1st column of file1 with the 1st line of the file2, 2nd column of file1 with the 2nd line of the file2, etc
cat file1
0.2 0.9 0.8 0.5 ...
0.6 0.5... (9 Replies)
I have a number, which I want to convert into the nearest floating number upto two places after the decimal point.
E.g.
1.2346 will become 1.23
but
1.2356 will become 1.24 .
Similarly
0.009 will be 0.01
and
0.001 will be 0.00 or 0.0 (not 0, wnat to keep the decimal... (1 Reply)
Hello Guys,
I have a floating point number 1.14475E+15 I want to convert this number in to full number (Integer or Big integer). I tried couple of functions it did not work. When I use INT=${FLOAT/.*} I am getting value as 1. I don't want a truncated value
#!/bin/bash
#... (9 Replies)
Hello, I have two edgelists. One bigger list master.txt and a subset of that, child.txt. I want to print out all the edges in master.txt which is not there in child.txt. I have done it the Python way, but its taking way to much time as the number of edges are huge. (one thing is that A-B and B-A... (7 Replies)
Discussion started by: Sanchari
7 Replies
LEARN ABOUT OPENSOLARIS
cmp
cmp(1) User Commands cmp(1)NAME
cmp - compare two files
SYNOPSIS
cmp [-l | -s] file1 file2 [skip1] [skip2]
DESCRIPTION
The cmp utility compares two files. cmp writes no output if the files are the same. Under default options, if they differ, it writes to
standard output the byte and line numbers at which the first difference occurred. Bytes and lines are numbered beginning with 1. If one
file is an initial subsequence of the other, that fact is noted. skip1 and skip2 are initial byte offsets into file1 and file2 respec-
tively, and can be either octal or decimal. A leading 0 denotes octal.
OPTIONS
The following options are supported:
-l Write the byte number (decimal) and the differing bytes (octal) for each difference.
-s Write nothing for differing files. Return exit status only.
OPERANDS
The following operands are supported:
file1 A path name of the first file to be compared. If file1 is -, the standard input is used.
file2 A path name of the second file to be compared. If file2 is -, the standard input is used.
If both file1 and file2 refer to standard input or refer to the same FIFO special, block special or character special file, an error
results.
USAGE
See largefile(5) for the description of the behavior of cmp when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
EXAMPLES
Example 1 Comparing Files Byte for Byte
The following example does a byte for byte comparison of file1 and file2:
example% cmp file1 file2 0 1024
It skips the first 1024 bytes in file2 before starting the comparison.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cmp: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following error values are returned:
0 The files are identical.
1 The files are different. This includes the case where one file is identical to the first part of the other.
>1 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO comm(1), diff(1), attributes(5), environ(5), largefile(5), standards(5)SunOS 5.11 19 Jul 2006 cmp(1)