Is it possible to Divide a negative number in bash script
I am using a small script to divide some numbers in a given file and display the output in another file. I am getting the following error
The script is :
Is it possible by some way to divide negative numbers? It would be helpful if someone can give some pointers.
Last edited by Scrutinizer; 03-06-2013 at 03:31 AM..
Reason: additional code tags
hi people,
I have a function which I am passing a stream which is basically postfix notation
if(isdigit(in.peek()))
{
in >> number;
nums.push(number);
}
else if (strchr("+-*/", in.peek( )) != NULL)
{
in >> symbol;
do_operation(symbol, nums, okay);
}
... (1 Reply)
Hi,
I want to search for a return code of -3. Using grep "-3" *.* is giving a syntax error. Please suggest as to how can we search for this pattern using grep.
Thanks,
Krishna (2 Replies)
Hi, does anyone know how to ignore whether a number is negative in a script. E.g. if I have a variable that contains -1200, how do I ignore the minus sign? (1 Reply)
Hi All,
Just faced an interesting thing in HP-UX. I was dividing 2955334616 / 2 by using echo `expr 2955334616 / 2` , and this ofcourse which expects 1477667308 to be returned. But I am getting -669816340 and I am :wall: how exactly this is possible. It is not one of the compliments (Ones or... (4 Replies)
Hi All,
I am stuck with this problem.
I have some 100000 (.dat) 1.dat, 2.dat,3.dat etc until 100000.dat files which look like this:
1.dat
1
2
3
4
0.99
4.54
All my files 1.dat until 100000.dat look the same but with different numbers.
I have to first add all the numbers in each... (1 Reply)
Hello, I am trying to write a bash script which will give me the most negative number. Here is an example input:
Ce 3.7729752124 -4.9505731588 -4.1061257680
Ce -6.9156611391 -0.5991784762 7.3051893138
Ce 7.6489739875 0.3513020731 ... (6 Replies)
I would like to print the number of records of 2 files, and divide the two numbers
awk '{print NR}' file1 > output1
awk '{print NR}' file2 > output2
paste output1 output2 > output
awl '{print $1/$2}' output > output_2
is there a faster way? (8 Replies)
Hi All,
I am trying to compare two negative numbers using awk on linux.But it is giving me wrong result.Same code is working perfectly on solaris.
print ((0+new_price) < MIN_PRICE)
e.g If I try to compare -1.32(new_price) and -500(min_price) using "<" operator, output is 1 i.e true.
... (5 Replies)
My script have to read logfile, and take some action, if in pattern are strings:
1) exit 0 strings pattern
... "INF - Status"... success
2) exit 1 (! as not) strings pattern
... "INF - Status"... !success
Simple example, what works
#!/bin/bash
tail -f regex.log | while read LOGLINE
... (7 Replies)
Hi ALL,
I am having semi column separated file as below. I am having negative values for the records starting with 11095. How can I convert that positive number
I tried this below seems not working
sed 's/ \(*\)$/ -\1/;t;s/\(.*\)-/\1/ myfile
myfile... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies
LEARN ABOUT SUSE
basename
BASENAME(1) User Commands BASENAME(1)NAME
basename - strip directory and suffix from filenames
SYNOPSIS
basename NAME [SUFFIX]
basename OPTION
DESCRIPTION
Print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX.
--help display this help and exit
--version
output version information and exit
EXAMPLES
basename /usr/bin/sort
Output "sort".
basename include/stdio.h .h
Output "stdio".
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report basename bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
COPYRIGHT
Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO dirname(1), readlink(1)
The full documentation for basename is maintained as a Texinfo manual. If the info and basename programs are properly installed at your
site, the command
info coreutils 'basename invocation'
should give you access to the complete manual.
GNU coreutils 7.1 July 2010 BASENAME(1)