Sponsored Content
Top Forums Shell Programming and Scripting Use script to mkdir based on file's data Post 303012713 by Chubler_XL on Wednesday 7th of February 2018 07:30:21 PM
Old 02-07-2018
Another solution:

Code:
awk '{ N[int($1/stepsize)]=N[int($1/stepsize)]"\n"$0 }
END { for(i in N) {
   dir=sprintf("%d-%d",i*stepsize,(i+1)*stepsize-1)
   printf "[ -d %s ] || mkdir %s\n", dir, dir
   printf "cat > %s/f_%s <<EOF", dir, dir
   print N[i]
   print "EOF"
}
}' stepsize=10 infile | sh


Last edited by Chubler_XL; 02-07-2018 at 08:38 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

2. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

3. Shell Programming and Scripting

Awk based script to find the median of all individual columns in a data file

Hi All, I have some data like below. Step1,Param1,Param2,Param3 1,2,3,4 2,3,4,5 2,4,5,6 3,0,1,2 3,0,0,0 3,2,1,3 ........ so on Where I need to find the median(arithmetic) of each column from Param1...to..Param3 for each set of Step1 values. (Sort each specific column, if the... (5 Replies)
Discussion started by: ks_reddy
5 Replies

4. Shell Programming and Scripting

awk based script to print the "mode(statistics term)" for each column in a data file

Hi All, Thanks all for the continued support so far. Today, I need to find the most occurring string/number(also called mode in statistics terminology) for each column in a data file (.csv type). For one column of data(1.txt) like below Sample 1 2 2 3 4 1 1 1 2 I can find the mode... (6 Replies)
Discussion started by: ks_reddy
6 Replies

5. Shell Programming and Scripting

awk based script to find the average of all the columns in a data file

Hi All, I need the modification for the below mentioned code (found in one more post https://www.unix.com/shell-programming-scripting/27161-script-generate-average-values.html) to find the average values for all the columns(but for a specific rows) and print the averages side by side. I have... (4 Replies)
Discussion started by: ks_reddy
4 Replies

6. Shell Programming and Scripting

Generate tabular data based on a column value from an existing data file

Hi, I have a data file with : 01/28/2012,1,1,98995 01/28/2012,1,2,7195 01/29/2012,1,1,98995 01/29/2012,1,2,7195 01/30/2012,1,1,98896 01/30/2012,1,2,7083 01/31/2012,1,1,98896 01/31/2012,1,2,7083 02/01/2012,1,1,98896 02/01/2012,1,2,7083 02/02/2012,1,1,98899 02/02/2012,1,2,7083 I... (1 Reply)
Discussion started by: himanish
1 Replies

7. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file based on certain conditions

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies

8. Shell Programming and Scripting

Script for extracting data from csv file based on column values.

Hi all, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (3 Replies)
Discussion started by: Vivekit82
3 Replies

9. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies

10. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies
ODE(1)                                                        GNU Plotting Utilities                                                        ODE(1)

NAME
ode - numerical solution of ordinary differential equations SYNOPSIS
ode [ options ] [ file ] DESCRIPTION
ode is a tool that solves, by numerical integration, the initial value problem for a specified system of first-order ordinary differential equations. Three distinct numerical integration schemes are available: Runge-Kutta-Fehlberg (the default), Adams-Moulton, and Euler. The Adams-Moulton and Runge-Kutta schemes are available with adaptive step size. The operation of ode is specified by a program, written in its input language. The program is simply a list of expressions for the deriva- tives of the variables to be integrated, together with some control statements. Some examples are given in the EXAMPLES section. ode reads the program from the specified file, or from standard input if no file name is given. If reading from standard input, ode will stop reading and exit when it sees a single period on a line by itself. At each time step, the values of variables specified in the program are written to standard output. So a table of values will be produced, with each column showing the evolution of a variable. If there are only two columns, the output can be piped to graph(1) or a similar plotting program. OPTIONS
Input Options -f file --input-file file Read input from file before reading from standard input. This option makes it possible to work interactively, after reading a pro- gram fragment that defines the system of differential equations. Output Options -p prec --precision prec When printing numerical results, use prec significant digits (the default is 6). If this option is given, the print format will be scientific notation. -t --title Print a title line at the head of the output, naming the variables in each column. If this option is given, the print format will be scientific notation. Integration Scheme Options The following options specify the numerical integration scheme. Only one of the three basic options -R, -A, -E may be specified. The default is -R (Runge-Kutta-Fehlberg). -R [stepsize] --runge-kutta [stepsize] Use a fifth-order Runge-Kutta-Fehlberg algorithm, with an adaptive stepsize unless a constant stepsize is specified. When a con- stant stepsize is specified and no error analysis is requested, then a classical fourth-order Runge-Kutta scheme is used. -A [stepsize] --adams-moulton [stepsize] Use a fourth-order Adams-Moulton predictor-corrector scheme, with an adaptive stepsize unless a constant stepsize, stepsize, is specified. The Runge-Kutta-Fehlberg algorithm is used to get past `bad' points (if any). -E [stepsize] --euler [stepsize] Use a `quick and dirty' Euler scheme, with a constant stepsize. The default value of stepsize is 0.1. Not recommended for serious applications. The error bound options -r and -e (see below) may not be used if -E is specified. -h hmin [hmax] --step-size-bound hmin [hmax] Use a lower bound hmin on the stepsize. The numerical scheme will not let the stepsize go below hmin. The default is to allow the stepsize to shrink to the machine limit, i.e., the minimum nonzero double-precision floating point number. The optional argument hmax, if included, specifies a maximum value for the stepsize. It is useful in preventing the numerical rou- tine from skipping quickly over an interesting region. Error Bound Options -r rmax [rmin] --relative-error-bound rmax [rmin] The -r option sets an upper bound on the relative single-step error. If the -r option is used, the relative single-step error in any dependent variable will never exceed rmax (the default for which is 10^-9). If this should occur, the solution will be aban- doned and an error message will be printed. If the stepsize is not constant, the stepsize will be decreased `adaptively', so that the upper bound on the single-step error is not violated. Thus, choosing a smaller upper bound on the single-step error will cause smaller stepsizes to be chosen. A lower bound rmin may optionally be specified, to suggest when the stepsize should be increased (the default for rmin is rmax/1000). -e emax [emin] --absolute-error-bound emax [emin] Similar to -r, but bounds the absolute rather than the relative single-step error. -s --suppress-error-bound Suppress the ceiling on single-step error, allowing ode to continue even if this ceiling is exceeded. This may result in large numerical errors. Informational Options --help Print a list of command-line options, and exit. --version Print the version number of ode and the plotting utilities package, and exit. DIAGNOSTICS
Mostly self-explanatory. The biggest exception is `syntax error', meaning there is a grammatical error. Language error messages are of the form ode: nnn: message... where `nnn' is the number of the input line containing the error. If the -f option is used, the phrase "(file)" follows the `nnn' for errors encountered inside the file. Subsequently, when ode begins reading the standard input, line numbers start over from 1. No effort is made to recover successfully from syntactic errors in the input. However, there is a meager effort to resynchronize so more than one error can be found in one scan. Run-time errors elicit a message describing the problem, and the solution is abandoned. EXAMPLES
The program y' = y y = 1 print t, y step 0, 1 solves an initial value problem whose solution is y=e^t. When ode runs this program, it will write two columns of numbers to standard out- put. Each line will show the value of the independent variable t, and the variable y, as t is stepped from 0 to 1. A more sophisticated example would be sine' = cosine cosine' = -sine sine = 0 cosine = 1 print t, sine step 0, 2*PI This program solves an initial value problem for a system of two differential equations. The initial value problem turns out to define the sine and cosine functions. The program steps the system over a full period. AUTHORS
ode was written by Nicholas B. Tufillaro (nbt@reed.edu), and slightly enhanced by Robert S. Maier (rsm@math.arizona.edu) to merge it into the GNU plotting utilities. SEE ALSO
"The GNU Plotting Utilities Manual". BUGS
Email bug reports to bug-gnu-utils@gnu.org. FSF Dec 1998 ODE(1)
All times are GMT -4. The time now is 08:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy