06-20-2011
Can you explain what's wrong with the solutions above?
If you don't get the correct output, post a better input file and the desired output.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I am using a if condition within my awk script and I have a problem with the search pattern.
I would like awk to find all the fields starting with 123. For now I have something like that:
awk '{for(i=1;i<9;i+=2)if($i=="123"...)print $i}' test
but that is not working as... (2 Replies)
Discussion started by: jolecanard
2 Replies
2. Shell Programming and Scripting
Hi,
I have a log file which contains lines like below:
2010-07-19 07:13:19,021 ERROR system ...(text)
2010-07-19 07:22:03,427 ERROR system ...(text)
class com... (text)
2010-07-19 07:23:19,026 ERROR system ...(text)
class com... (text)
each line is a separate line... I am given the a... (14 Replies)
Discussion started by: a27wang
14 Replies
3. Shell Programming and Scripting
Dear Friends,
I have a flat file. To pick certain details we have written an awk where we are facing difficulty.
Sample of flat file.
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
line 11
line 12
line 13
line 14 (Matching pattern "Lkm_i-lnr:"can be... (4 Replies)
Discussion started by: anushree.a
4 Replies
4. UNIX for Dummies Questions & Answers
Hi All,
I am trying to find numbers with balance greater than 1 and less than equal 2 from the below file using awk
Input file
num ,bal
100199,1.708
100225,0
100226,0
100228,0.771166
100232,2
output file
100199,1.708
100232,2
I am using the following command for this... (2 Replies)
Discussion started by: pistachio
2 Replies
5. Shell Programming and Scripting
Here Is a problem I am facing with awk.
Query --> I want to search for a string in a file and print next 15 lines below the matched string.
1.We do not have GNU grep so cannot use grep -A or grep -B commands.
2. Instead of passing the search pattern as a string to awk. I want the awk to... (4 Replies)
Discussion started by: togotutor
4 Replies
6. Shell Programming and Scripting
Hello Guyz
I have been following this forum for a while and the solutions provided are super useful. I currently have a scenario where i need to search for a pattern and start searching by keeping the first pattern as a baseline
ABC
DEF
LMN
EFG
HIJ
LMN
OPQ
In the above text i need to... (8 Replies)
Discussion started by: RickCharles
8 Replies
7. Shell Programming and Scripting
Want to fetch a column with multiple pattern using awk.
How to achieve the same.
Tried
cat test
address : 10.63.20.92/24
address : 10.64.22.93/24
address : 10.53.40.91/24
cat test | awk '{print $3}' |awk -F "/" '{print $1}'
10.63.20.92
10.64.22.93
10.53.40.91
Is there any... (2 Replies)
Discussion started by: Manasa Pradeep
2 Replies
8. Shell Programming and Scripting
Want to search a pattern in column
using the below command which not helpful
awk -F"\|" '$1 == '"${VAR}"' {print $1,$2}' file
how to search using "==" with variable other than the below case.
awk -F"\|" '$1 ~ /'"${VAR}"'/ {print $1,$2}' file (14 Replies)
Discussion started by: Roozo
14 Replies
9. UNIX for Beginners Questions & Answers
I have this fileA
TEST FILE ABC
this file contains ABC;
TEST FILE DGHT this file contains DGHT;
TEST FILE 123
this file contains ABC,
this file contains DEF,
this file contains XYZ,
this file contains KLM
;
I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies
10. Shell Programming and Scripting
Hello,
We have wrote shell script for multiple file name search pattern.
file format: <numner>_<20180809>.txt
starting with single number and ending with 8 digits number
Command:
awk -v string="12_1234" -v serch="^+_+$" "BEGIN{ if (string ~/serch$/) print string }"
If sting matches... (4 Replies)
Discussion started by: koti_rama
4 Replies
LEARN ABOUT XFREE86
fitcircle
FITCIRCLE(l) FITCIRCLE(l)
NAME
fitcircle - find mean position and pole of best-fit great [or small] circle to points on a sphere.
SYNOPSIS
fitcircle [ xyfile ] -Lnorm [ -H[nrec] ] [ -S ] [ -V ] [ -: ] [ -bi[s][n] ]
DESCRIPTION
fitcircle reads lon,lat [or lat,lon] values from the first two columns on standard input [or xyfile]. These are converted to cartesian
three-vectors on the unit sphere. Then two locations are found: the mean of the input positions, and the pole to the great circle which
best fits the input positions. The user may choose one or both of two possible solutions to this problem. The first is called -L1 and the
second is called -L2. When the data are closely grouped along a great circle both solutions are similar. If the data have large dispersion,
the pole to the great circle will be less well determined than the mean. Compare both solutions as a qualitative check.
The -L1 solution is so called because it approximates the minimization of the sum of absolute values of cosines of angular distances. This
solution finds the mean position as the Fisher average of the data, and the pole position as the Fisher average of the cross-products
between the mean and the data. Averaging cross-products gives weight to points in proportion to their distance from the mean, analogous to
the "leverage" of distant points in linear regression in the plane.
The -L2 solution is so called because it approximates the minimization of the sum of squares of cosines of angular distances. It creates a
3 by 3 matrix of sums of squares of components of the data vectors. The eigenvectors of this matrix give the mean and pole locations. This
method may be more subject to roundoff errors when there are thousands of data. The pole is given by the eigenvector corresponding to the
smallest eigenvalue; it is the least-well represented factor in the data and is not easily estimated by either method.
-L Specify the desired norm as 1 or 2, or use -L or -L3 to see both solutions.
OPTIONS
xyfile ASCII [or binary, see -b] file containing lon,lat [lat,lon] values in the first 2 columns. If no file is specified, fitcircle will
read from standard input.
-H Input file(s) has Header record(s). Number of header records can be changed by editing your .gmtdefaults file. If used, GMT default
is 1 header record.
-S Attempt to fit a small circle instead of a great circle. The pole will be constrained to lie on the great circle connecting the pole
of the best-fit great circle and the mean location of the data.
-V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].
-: Toggles between (longitude,latitude) and (latitude,longitude) input/output. [Default is (longitude,latitude)]. Applies to geo-
graphic coordinates only.
-bi Selects binary input. Append s for single precision [Default is double]. Append n for the number of columns in the binary file(s).
[Default is 2 input columns].
EXAMPLES
Suppose you have lon,lat,grav data along a twisty ship track in the file ship.xyg. You want to project this data onto a great circle and
resample it in distance, in order to filter it or check its spectrum. Try:
fitcircle ship.xyg -L2
project ship.xyg -Cox/oy -Tpx/py -S -pz | sample1d -S-100 -I1 > output.pg
Here, ox/oy is the lon/lat of the mean from fitcircle, and px/py is the lon/lat of the pole. The file output.pg has distance, gravity data
sampled every 1 km along the great circle which best fits ship.xyg
SEE ALSO
gmt(1gmt), project(1gmt), sample1d(1gmt)
1 Jan 2004 FITCIRCLE(l)