Sponsored Content
Top Forums Shell Programming and Scripting Add and divide each numbers with the added number Post 302561500 by ahamed101 on Tuesday 4th of October 2011 10:01:15 AM
Old 10-04-2011
Try this...
Code:
#!/bin/bash

for file in *.dat
do
  out_file=$( echo ${file%%.*} ).div
  awk -v out_file=$out_file '
  { a=a+$0; b[++i]=$0} END{for(j=1;j<=i;j++){print b[j]/a > out_file} } ' $file
done

--ahamed
This User Gave Thanks to ahamed101 For This Post:
 

10 More Discussions You Might Find Interesting

1. AIX

How to replace many numbers with one number in a file

How to replace many numbers with one number in a file. Many numbers like 444565,454678,443298,etc. i want to replace these with one number (300).Please halp me out. (2 Replies)
Discussion started by: vpandey
2 Replies

2. Shell Programming and Scripting

Divide numbers into intervals

divide input values into specified number (-100 or -200) according to the key (a1 or a2 ....) For ex: if we give -100 in the command line it would create 100 number intervals (1-100, 100-200, 200-300) untill it covers the value 300 in a1. Note: It should work the same even with huge numbers... (3 Replies)
Discussion started by: ruby_sgp
3 Replies

3. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

4. Shell Programming and Scripting

Closest Number from a Range of Numbers

out of a range of numbers, how can i pick out the number that is the closest to any arbitrary/random number that a user supplies? say the range of numbers are between 1 - 90000. but that doesn't mean each number exist between 1 - 90000. the range of numbers could be for example: 1, 3, 4, 6,... (6 Replies)
Discussion started by: SkySmart
6 Replies

5. Shell Programming and Scripting

AWK print number of records, divide this number

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)
Discussion started by: programmerc
8 Replies

6. Shell Programming and Scripting

Print numbers between two number ranges

Hi, I have a list.txt file with number ranges and want to print/save new all.txt file with all the numbers and between the numbers. == list.txt == 65936 65938 65942 && 65943 65945 ... (7 Replies)
Discussion started by: AK47
7 Replies

7. Shell Programming and Scripting

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 basename: invalid option -- '5' Try `basename --help' for more information. (standard_in) 1: syntax error The script is : #!/bin/bash for i in `cat... (4 Replies)
Discussion started by: kmnr877
4 Replies

8. Shell Programming and Scripting

Divide number of lines by the size of the same file. And create relational table.

I basically need to do what the title says. I have my text file. I'm still pretty new at this. At the moment I know that: 1. wc -l file.txt To get the number of lines. 2. ls -lh file.txt To get the file size. But I need to divide both numbers. Then I need to save the output in a... (7 Replies)
Discussion started by: PainMaker101
7 Replies

9. Shell Programming and Scripting

Script to divide/expand first digit to show some numbers

Hello to everyone, I have this complex problem and I don't how to do it. I'm not sure if awk could be a good choice to do it or could be easiest in bash or perl. A kind of introduction would be: - I have a digit, lets say 3. - I can expand/spread out the digit 3 to cover all possible... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

10. Shell Programming and Scripting

Divide the numbers in file

Dear ALL, I have sample file : tx_bytes: 2422, tx_packets: 13, uptime: 16119, tx_bytes: 2342, tx_packets: 14, uptime: 11009, tx_bytes: 252, tx_packets: 12, uptime: 3113, my formula : minutes=$(( uptime/60%60 )) hours=$(( uptime/60/60%24 )) (3 Replies)
Discussion started by: gnulyn
3 Replies
RG::Reprof(3pm) 					User Contributed Perl Documentation					   RG::Reprof(3pm)

NAME
RG::Reprof::Reprof - protein secondary structure and accessibility predictor SYNOPSIS
use RG::Reprof::Reprof; DESCRIPTION
See module commented source for further details. Methods OBJ RG::Reprof::Reprof->new( model_dir => PATH ) Default model_dir: /tmp/lkajan/root/share/reprof. Returns new instance of RG::Reprof::Reprof. int $OBJ->run( input_file => PATH, out_file => PATH, mutation_file => PATH, specific_models => hashref, output_func => coderef ) out_file may be a directory. mutation_file may be undefined. specific_models may be undefined. This is a hash of model and feature files with 'model_name' keys like: { 'fub_model' => '/path/to/model_file', 'fub_features' => '/path/to/features_file' } Check the module source for the list for model names. void output_func( out_file, sec_pred, acc_pred, sequence ) - function to call when output is ready. If undefined, the built-in write_output() function is called that prints results to one or more files. The following positional parameters are passed to this function: out_file Output file name. sec_pred Secondary structure prediction, see source for details. acc_pred Accessibility prediction, see source for details. sequence Reference to array of residues of input sequence (e.g. [ 'M', 'A', 'G', ... ] ). AUTHOR
Original version by Peter Hoenigschmid <hoenigschmid@rostlab.org> and Burkhard Rost. Some perl module work and documentation by Laszlo Kajan <lkajan@rostlab.org>. SEE ALSO
<http://rostlab.org/> perl v5.14.2 2012-01-13 RG::Reprof(3pm)
All times are GMT -4. The time now is 01:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy