Sponsored Content
Top Forums UNIX for Dummies Questions & Answers looping through file and creating seperate files Post 302575928 by frappa on Wednesday 23rd of November 2011 08:56:21 AM
Old 11-23-2011
Hi,

please look at similar post:
https://www.unix.com/shell-programmin...ple-files.html

I think you can do something like:
Code:
$ awk ' /AMC/ { print $0 >> "out1.txt" } ; /AAO/ { print $0 >> "out2.txt" } ' millionrecords.txt

so that out1.txt contains only rows with AMC, and out2 contains only rows with AAO.

see ya
fra

Last edited by frappa; 11-23-2011 at 10:01 AM.. Reason: added awk one-liner as example
This User Gave Thanks to frappa For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split File into seperate files

Hi, So I have a text file which I want to separate into separate text files. I would use the split command but the problem here is that the text file is separated by delimiters. For example: blah blah blah ------ more text ----- and some more text So basically the first part should be... (4 Replies)
Discussion started by: eltinator
4 Replies

2. UNIX for Dummies Questions & Answers

comparing strings in seperate files

Hello, I am comparing files with for mismatches using fgrep but I've run into a problem. fgrep -vf $file1 $file2 > mismatches.dat file1 and file2 both contain file names on each line file1 has filenames which are up to 92 characters long and contain the "$" char. example file name:... (2 Replies)
Discussion started by: orahi001
2 Replies

3. Solaris

Problem creating sol8 container using seperate / /usr and /var ufsdumps

Hello experts New to solaris 8 containers and zones in general and I'm having some problems creating a Solaris 8 container using ufsdumps of /, /usr and /var. I have created the zone which worked fine and a running the following command. zoneadm -z zone_s8 install -v -p -a /root.ufs ... (2 Replies)
Discussion started by: BrokeIt
2 Replies

4. UNIX for Dummies Questions & Answers

Help in Array looping and creating multiple lines

hi Gurus, I'm a newbie in scripting please check my script if this is correct. I think there's something wrong with it but I;m not sure. I'm trying to create multiple lines using awk from external xml files but i want to add additonal info in the data manually Since i don't knwo how to... (0 Replies)
Discussion started by: sexyTrojan
0 Replies

5. Homework & Coursework Questions

File Looping - Looking for executable files - Need help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! Hello all, I have posted here before and really was blown away by the amount of assistance I received. I was able to finish my homework without a problem! But, yet again, our... (6 Replies)
Discussion started by: Bob07
6 Replies

6. Shell Programming and Scripting

While or For with looping contructs? to create files from contents of a text file

Hi so far I created this script: vi loop.beta.sh for i in `cat extract.filenames.tabc` do echo $i done>$i === This is the original text file. $ more tabc.txt -rwx------- 1 alice staff 1586 2010-11-05 02:27 request-key .conf -rwx------- 1 ted staff 126 ... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

7. Shell Programming and Scripting

Not looping or creating files

So my script is supposed to repeat for every server in my file, but as of now it is getting stuck on my awk commands # Read file cred.txt (with one IP per line), connect to servers (one at a time), and download directory listing i=1 param=$(sed -n "{$1}p" $parm_dir/cdm_param.txt) #Get the last... (6 Replies)
Discussion started by: MJCreations
6 Replies

8. Shell Programming and Scripting

Seperate Odd and Even numbers from 1 file to 2 files

Hey guys. I have been trying to figure out an easy way to seperate a liste of 150k numbers (10 digits) in a .txt file into odd and even numbers with each of their own files, for a project at work. I've tried Excel, but it was too much for it and it wasnt very simple. So i gave up after... (13 Replies)
Discussion started by: TranceC
13 Replies

9. Shell Programming and Scripting

Looping the files for getting the file size information

Am using Linux 3.10 years.txt is input source file which has the list of year like below 2013 2014 2015 2016 Other Input files are XX_TEST1_YR2016_01012018.csv XX_TEST1_YR2015_01012018.csv XX_TEST1_YR2014_01012018.csv XX_TEST1_YR2013_01012018.csv XX_TEST2_YR2016_01012018.csv... (2 Replies)
Discussion started by: weknowd
2 Replies

10. UNIX for Beginners Questions & Answers

For loop for seperate files

For shell script. If I had two separate files, file.txt and file1.txt and each has just a list of names from the who command. How would I create an if loop to compare each name? (1 Reply)
Discussion started by: Eric7giants
1 Replies
SPHINTERPOLATE(1gmt)					       Generic Mapping Tools					      SPHINTERPOLATE(1gmt)

NAME
sphinterpolate - Gridding in tension of spherical data SYNOPSIS
sphinterpolate infiles -Ggrdfile [ -F ] [ -H[i][nrec] ] [ -Ixinc[unit][=|+][/yinc[unit][=|+]] ] [ -Qmode[/options] ] [ -Rwest/east/south/north[r] ] [ -V ] [ -Z ] [ -:[i|o] ] [ -b[i|o][s|S|d|D[ncol]|c[var1/...]] ][ -m[i|o][flag] ] DESCRIPTION
sphinterpolate reads one or more ASCII [or binary] files (or standard input) containing lon, lat, f and performs a Delaunay triangulation to set up a spherical interpolation in tension. The final grid is saved to the specified file. Several options may be used to affect the outcome, such as choosing local versus global gradient estimation or optimize the tension selection to satisfy one of four criteria. infiles Data files with the (lon, lat, f) coordinates in ASCII (or binary; see -b). If no files are given the standard input is read. -G Name of the output grid to hold the interpolation. OPTIONS
-F Force pixel node registration [Default is gridline registration]. (Node registrations are defined in GMT Cookbook Appendix B on grid file formats.) -H Input file(s) has header record(s). If used, the default number of header records is N_HEADER_RECS. Use -Hi if only input data should have header records [Default will write out header records if the input data have them]. Blank lines and lines starting with # are always skipped. -I x_inc [and optionally y_inc] is the grid spacing. Optionally, append a suffix modifier. Geographical (degrees) coordinates: Append m to indicate arc minutes or c to indicate arc seconds. If one of the units e, k, i, or n is appended instead, the increment is assumed to be given in meter, km, miles, or nautical miles, respectively, and will be converted to the equivalent degrees longitude at the middle latitude of the region (the conversion depends on ELLIPSOID). If /y_inc is given but set to 0 it will be reset equal to x_inc; otherwise it will be converted to degrees latitude. All coordinates: If = is appended then the corresponding max x (east) or y (north) may be slightly adjusted to fit exactly the given increment [by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of giving an increment you may specify the number of nodes desired by appending + to the sup- plied integer argument; the increment is then recalculated from the number of nodes and the domain. The resulting increment value depends on whether you have selected a gridline-registered or pixel-registered grid; see Appendix B for details. Note: if -Rgrdfile is used then grid spacing has already been initialized; use -I to override the values. -Q Specify one of four ways to calculate tension factors to preserve local shape properties or satisfy arc constraints [Default is no tension]. -Q0 Piecewise linear interpolation; no tension is applied. -QQ1 Smooth interpolation with local gradient estimates. -QQ2 Smooth interpolation with global gradient estimates. You may optionally append /N/M/U, where N is the number of iterations used to converge at solutions for gradients when variable tensions are selected (e.g., -T only) [3], M is the number of Gauss-Seidel itera- tions used when determining the global gradients [10], and U is the maximum change in a gradient at the last iteration [0.01]. -QQ3 Smoothing. Optionally append /E/U [/0/0], where E is Expected squared error in a typical (scaled) data value, and U is Upper bound on weighted sum of squares of deviations from data. -R west, east, south, and north specify the Region of interest, and you may specify them in decimal degrees or in [+-]dd:mm[:ss.xxx][W|E|S|N] format. Append r if lower left and upper right map coordinates are given instead of w/e/s/n. The two shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively, with -90/+90 in latitude). Alterna- tively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. -T Use variable tension (ignored with -Q0 [constant] -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. -Z Before interpolation, scale data by the maximum data range [no scaling]. -: Toggles between (longitude,latitude) and (latitude,longitude) input and/or output. [Default is (longitude,latitude)]. Append i to select input only or o to select output only. [Default affects both]. -bi Selects binary input. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Option- ally, append ncol, the number of columns in your binary input file if it exceeds the columns needed by the program. Or append c if the input file is netCDF. Optionally, append var1/var2/... to specify the variables to be read. [Default is 3 input columns]. -bo Selects binary output. Append s for single precision [Default is d (double)]. Uppercase S or D will force byte-swapping. Option- ally, append ncol, the number of desired columns in your binary output file. [Default is same as input]. -m Multiple segment file(s). Segments are separated by a special record. For ASCII files the first character must be flag [Default is '>']. For binary files all fields must be NaN and -b must set the number of output columns explicitly. By default the -m setting applies to both input and output. Use -mi and -mo to give separate settings to input and output. ASCII FORMAT PRECISION
The ASCII output formats of numerical data are controlled by parameters in your .gmtdefaults4 file. Longitude and latitude are formatted according to OUTPUT_DEGREE_FORMAT, whereas other values are formatted according to D_FORMAT. Be aware that the format in effect can lead to loss of precision in the output, which can lead to various problems downstream. If you find the output is not written with enough pre- cision, consider switching to binary output (-bo if available) or specify more decimals using the D_FORMAT setting. GRID VALUES PRECISION
Regardless of the precision of the input data, GMT programs that create grid files will internally hold the grids in 4-byte floating point arrays. This is done to conserve memory and furthermore most if not all real data can be stored using 4-byte floating point values. Data with higher precision (i.e., double precision values) will lose that precision once GMT operates on the grid or writes out new grids. To limit loss of precision when processing data you should always consider normalizing the data prior to processing. EXAMPLES
To interpolate the points in the file testdata.txt on a global 1x1 degree grid with no tension, use sphinterpolate testdata.txt -Rg -I1 -Gsolution.grd SEE ALSO
GMT(1), greenspline(1) sphdistance(1) sphtriangulate(1) triangulate(1) REFERENCES
Renka, R, J., 1997, Algorithm 772: STRIPACK: Delaunay Triangulation and Voronoi Diagram on the Surface of a Sphere, AMC Trans. Math. Soft- ware, 23(3), 416-434. Renka, R, J,, 1997, Algorithm 773: SSRFPACK: Interpolation of scattered data on the Surface of a Sphere with a surface under tension, AMC Trans. Math. Software, 23(3), 435-442. GMT 4.5.7 15 Jul 2011 SPHINTERPOLATE(1gmt)
All times are GMT -4. The time now is 08:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy