Sponsored Content
Top Forums Shell Programming and Scripting Loop through file and write out lines to file(s) Post 77115 by r2007 on Tuesday 5th of July 2005 12:21:06 AM
Old 07-05-2005
Code:
awk 'BEGIN{of="file0.txt"}/^Header/{close(of);of="file"++i".txt";}{print>of}' file.txt

1. begin != BEGIN --- typo, Thank you!
2. '>' != '>>' --- it is right '>' != '>>', but using '>' is better than '>>' in this thread.
3. depending on the inital assumptions: is it the string 'Header' that segregate the records or is there some other record segregation logic --- agree, hope Jtrinh can talk more about the rule of the file.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Loop through the lines in a file?

How do I loop through the lines of a file? Each line of the file will be the name of a server. Like: server1.stuff.com server2.stuff.com For each server I want to do a secure copy of the file to the other server. This will be a cron job so I guess it needs to run in just SH. I... (3 Replies)
Discussion started by: jimmy
3 Replies

2. Shell Programming and Scripting

trying to write a script to loop through a port info file

Below is part of a script i have written to loop through part of a port info file. How do i continue the script to get info for OS Device Name, manufacturer and then put information into an array? HBA Port WWN: 10000000c9420b4b OS Device Name: /dev/cfg/c10 Manufacturer: Emulex... (5 Replies)
Discussion started by: rcon1
5 Replies

3. Shell Programming and Scripting

Push records to array during implicit loop and write to file

NEWBIE ALERT! Hi, I'm 1 month into learning Perl and done reading "Minimal Perl" by Tim Maher (which I enjoyed enoumously). I'm not a programmer by profession but want to use Perl to automate various tasks at my job. I have a problem (obviously) and are looking for your much appreciated help.... (0 Replies)
Discussion started by: jospan
0 Replies

4. UNIX for Dummies Questions & Answers

Unable to write to a file within a loop

Hi All, Following is the program that i have written in cygwin. The redirection of the unfound $param1 to error.txt file doesnt work.Can any one help? #!/usr/bin/sh fname=$1 sed 's/ //g' "$fname" > fname1 while read i do echo $i > file1 #param1 is script name ... (1 Reply)
Discussion started by: janardhanamk
1 Replies

5. Shell Programming and Scripting

how to write multiple lines to a file using shell script?

I need to create an xml using shell script, but i first want to know how can i write multiple lines to file using shell script? (7 Replies)
Discussion started by: vel4ever
7 Replies

6. UNIX for Dummies Questions & Answers

analyze lines in a file by loop

Hi Dears, I use the below code to analyze lines in a file: for line in `cat ucsv` do echo $line //analyze statements donehowever, if line contains space char, it will be broken. for example, if file content is: #login,full name,email,project,role,action gmwen,Bruce... (3 Replies)
Discussion started by: crest.boy
3 Replies

7. UNIX for Dummies Questions & Answers

Simple script to write new lines in a text file

Hello, I have a comma seperated data sheet with multiple fields of biological data. One column contains the ID name of the sample, where there could be more than one sample separated by a comma. I would like a script that reads this field, and for each sample ID, copies the entire line and writes... (18 Replies)
Discussion started by: torchij
18 Replies

8. UNIX for Dummies Questions & Answers

Count the lines with the same values in a column and write the output to a file

Hey everyone! I have a tab delimited data set which I want to create an output contained the calculation of number of those lines with a certain value in 2nd and 3rd column. my input file is like this: ID1 1 10M AAATTTCCGG ID2 5 4M ACGT ID3 5 8M ACCTTGGA ID4 5 ... (7 Replies)
Discussion started by: @man
7 Replies

9. Shell Programming and Scripting

ksh Loop through file one, remove lines from file two

Good Afternoon, I start with a file named biglist.txt. I have another file smallerlist. txt I want to remove the lines from smallerlist.txt from biglist.txt and leave those lines that do not reside in smallerlist.txt. Thanks !! (2 Replies)
Discussion started by: popeye
2 Replies

10. Shell Programming and Scripting

Using sed in a loop/to remove lines contained in variable from file

I've tried numerous commands, but I am not sure how to use sed in a loop. This is what I have: VARZ contains CARD_FILE_LIST and it also contains CARD_FILE_LIST2 so echo "$VARZ" CARD_FILE_LIST CARD_FILE_LIST2 I have a file with 60 lines in /tmp/testfile it and I want those lines deleted... (3 Replies)
Discussion started by: newbie2010
3 Replies
X2SYS_SOLVE(1gmt)					       Generic Mapping Tools						 X2SYS_SOLVE(1gmt)

NAME
x2sys_solve - Determine systematic corrections from crossovers SYNOPSIS
x2sys_solve -Ccolumn -TTAG -Emode [ COE_list.d ] [ -V ] [ -W ] [ -Z ] [ -bi[s|S|d|D[ncol]|c[var1/...]] ] DESCRIPTION
x2sys_solve will use the supplied crossover information to solve for systematic corrections that can then be applied per track to improve data quality. Several systematic corrections can be solved for using a least-squares approach. Note: Only one data column can be processed at the time. -T Specify the x2sys TAG which tracks the attributes of this data type. -C Specify which data column you want to process. Needed for proper formatting of the output correction table and must match the same option used in x2sys_list when preparing the input data. -E The correction type you wish to model. Choose among the following functions f(p), where p are the m parameters per track that we will fit simultaneously using a least squares approach: c will fit f(p) = a (a constant offset); records must contain cruise ID1, ID2, COE. d will fit f(p) = a + b * d (linear drift; d is distance; records must contain cruise ID1, ID2, d1, d2, COE. g will fit f(p) = a + b sin(y)^2 (1980-1930 gravity correction); records must contain cruise ID1, ID2, latitude y, COE. h will fit f(p) = a + b cos(H) + c cos(2H) + d sin(H) + e sin(2H) (magnetic heading correction); records must contain cruise ID1, ID2, heading H, COE. s will fit f(p) = a * z (a unit scale correction); records must contain cruise ID1, ID2, z1, z2. t will fit f(p) = a + b * (t - t0) (linear drift; t0 is the start time of the track); records must contain cruise ID1, ID2, t1-t0, t2-t0, COE. OPTIONS
No space between the option flag and the associated arguments. COE_list.d Name of file with the required crossover columns as produced by x2sys_list. NOTE: If -bi is used then the first two columns are expected to hold the integer track IDs; otherwise we expect those columns to hold the text string names of the two tracks. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. -W Means that each input records has an extra column with the composite weight for each crossover record. These are used to obtain a weighted least squares solution [no weights]. -Z For -Ed and -Et, determine the earliest time or shortest distance for each track, then use these values as the local origin for time duration or distance calculations. The local origin is then included in the correction table [Default uses 0]. -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. EXAMPLES
To fit a simple bias offset to faa for all tracks under the MGD77 tag, try x2sys_list COE_data.txt -V -TMGD77 -Cfaa -Fnc > faa_coe.txt x2sys_solve faa_coe.txt -V -TMGD77 -Cfaa -Ec > coe_table.txt To fit a faa linear drift with time instead, try x2sys_list COE_data.txt -V -TMGD77 -Cfaa -FnTc > faa_coe.txt x2sys_solve faa_coe.txt -V -TMGD77 -Cfaa -Et > coe_table.txt To estimate heading corrections based on magnetic crossovers associated with the tag MGD77 from the file COE_data.txt, try x2sys_list COE_data.txt -V -TMGD77 -Cmag -Fnhc > mag_coe.txt x2sys_solve mag_coe.txt -V -TMGD77 -Cmag -Eh > coe_table.txt To estimate unit scale corrections based on bathymetry crossovers, try x2sys_list COE_data.txt -V -TMGD77 -Cdepth -Fnz > depth_coe.txt x2sys_solve depth_coe.txt -V -TMGD77 -Cdepth -Es > coe_table.txt SEE ALSO
x2sys_binlist(1), x2sys_cross(1), x2sys_datalist(1), x2sys_get(1), x2sys_init(1), x2sys_list(1), x2sys_put(1), x2sys_report(1) GMT 4.5.7 15 Jul 2011 X2SYS_SOLVE(1gmt)
All times are GMT -4. The time now is 02:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy