11-16-2006
equation calculation on Unix
Hay, guys,
Any ideas how to calculate like this:
in first file, there're number of lines listing 2+3, 6*9 .......
Then, how to get the result and put them in another file in format:
2+3 5
6*9 54
......
sheerly by shell command, no scripts required.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Is there a way to evaluate an equation contained in a string within an AWK script?
For example:
A = "(5*2)-1" (this equation is read from a file and varies line by line)
In this example, I can't see any way to get an answer of 9 unless I do:
cmd = "awk 'BEGIN{print "A"}'"
cmd |... (3 Replies)
Discussion started by: srdgeo
3 Replies
2. Shell Programming and Scripting
Hi, I am in ksh88
I am trying to get the result of the calculation using 3 variables:
TOTAL
CAPACITY
and get the following error:
$DB_CAPACITY=(( $DB_SIZE * 100 / $TOTAL ))
ksh: syntax error: `((' unexpected
I cannot figure out what am I doing wrong... Thanks for any help -A (2 Replies)
Discussion started by: aoussenko
2 Replies
3. Shell Programming and Scripting
if input to the perl program is ' ( p * ((a+b) * (c+d))) + q ' it shuld give the output as ' pac + pad + pbc + pbd + q ' .can anyone suggest a way to do this ? (7 Replies)
Discussion started by: Anuj8584
7 Replies
4. High Performance Computing
I'm running a MPI program using a cluster of 4 machines(different machines of different processing power,cpu utilization etc.). I'm trying to balance the computation among the machine to get the minimum execution time for that. I tried to balance it by creating a threshold value by taking the load... (1 Reply)
Discussion started by: chamila1986
1 Replies
5. Shell Programming and Scripting
Hi, i have a large file like this:
Contig1 1 5
Contig1 2 4
Contig1 3 3
Contig1 4 5
Contig1 5 3
Contig1 6 4
Contig2 1 3
Contig2 2 7
Contig2 3 2
Contig2 4 9
Contig2 5 10
Contig2 6 3
Contig2 7 7
Contig2 8 2
Contig2 9 7
Contig2 10 5
contig1 2 4
contig1 3 3
contig1 4 5 (3 Replies)
Discussion started by: the_simpsons
3 Replies
6. Shell Programming and Scripting
HI All,
I have a script in bash that i want that script will perform action
When the size of a particular folder exceeds the 80%.
Here is an example of script that result is exactly 80% :
#!/bin/bash
CHECK=$(df -h /var/log/syslog | grep '80%' | xargs echo | cut -d' ' -f5)
if ];... (1 Reply)
Discussion started by: Aviel.shani
1 Replies
7. Homework & Coursework Questions
! The one-dimensional PDE for heat diffusion equation
! u_t=(D(u)u_x)_x + s where u(x,t) is the temperature,
! D(u) is the diffusivity and s(x,t) is a source term.
! Taking D(u)= 1 and s(x,t)=0 gives
! u_t= u_xx
! uniform one dimensional region |x|<1 for t>0
! uniform mesh size delta x=0.1
!... (1 Reply)
Discussion started by: watto1
1 Replies
8. UNIX for Dummies Questions & Answers
I want to automate change in 'from yyyy/mm/dd to yyyy/mm/dd' every month in a unix program.
For example in this month 'from yyyy/mm/dd to yyyy/mm/dd' is 'from 2014/10/01 to 2014/11/01' next month it should be 'from 2014/11/01 to 2014/12/01'
Can any one provide me the code for the above... (2 Replies)
Discussion started by: srinivas kasett
2 Replies
9. Programming
Well guys and gals I have discovered after all these years that Python does complex numbers without the 'complex()' function or 'cmath' import.
It is well known that Euler's Identity E**(i*pi)+1=0 so I decided to experiment
Last login: Fri Dec 13 18:27:30 on ttys000
AMIGA:amiga~> python3.8... (0 Replies)
Discussion started by: wisecracker
0 Replies
LEARN ABOUT REDHAT
file::listing
File::Listing(3) User Contributed Perl Documentation File::Listing(3)
NAME
parse_dir - parse directory listing
SYNOPSIS
use File::Listing;
for (parse_dir(`ls -l`)) {
($name, $type, $size, $mtime, $mode) = @$_;
next if $type ne 'f'; # plain file
#...
}
# directory listing can also be read from a file
open(LISTING, "zcat ls-lR.gz|");
$dir = parse_dir(*LISTING, '+0000');
DESCRIPTION
The parse_dir() routine can be used to parse directory listings. Currently it only understand Unix 'ls -l' and 'ls -lR' format. It should
eventually be able to most things you might get back from a ftp server file listing (LIST command), i.e. VMS listings, NT listings, DOS
listings,...
The first parameter to parse_dir() is the directory listing to parse. It can be a scalar, a reference to an array of directory lines or a
glob representing a filehandle to read the directory listing from.
The second parameter is the time zone to use when parsing time stamps in the listing. If this value is undefined, then the local time zone
is assumed.
The third parameter is the type of listing to assume. The values will be strings like 'unix', 'vms', 'dos'. Currently only 'unix' is
implemented and this is also the default value. Ideally, the listing type should be determined automatically.
The fourth parameter specifies how unparseable lines should be treated. Values can be 'ignore', 'warn' or a code reference. Warn means
that the perl warn() function will be called. If a code reference is passed, then this routine will be called and the return value from it
will be incorporated in the listing. The default is 'ignore'.
Only the first parameter is mandatory.
The return value from parse_dir() is a list of directory entries. In a scalar context the return value is a reference to the list. The
directory entries are represented by an array consisting of [ $filename, $filetype, $filesize, $filetime, $filemode ]. The $filetype value
is one of the letters 'f', 'd', 'l' or '?'. The $filetime value is the seconds since Jan 1, 1970. The $filemode is a bitmask like the
mode returned by stat().
CREDITS
Based on lsparse.pl (from Lee McLoughlin's ftp mirror package) and Net::FTP's parse_dir (Graham Barr).
libwww-perl-5.65 1999-03-20 File::Listing(3)