Sponsored Content
Full Discussion: awk Loop 4 digit fields
Top Forums Shell Programming and Scripting awk Loop 4 digit fields Post 302576137 by danmero on Wednesday 23rd of November 2011 06:11:37 PM
Old 11-23-2011
Quote:
Originally Posted by sdf
I would like to loop until NF and while $i does not match ($i ~ /[[:digit:]]{4}/) anymore then print all matching $i and exit.
Code:
gawk '{for(;i++<NF;) {if($i ~ /[[:digit:]]{4}/)print $i};exit}' file

Is that what you want?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK create loop for fields

Hi everybody: I just create awk script. This script calculate the average of a field, but i want to do it for every fields. The original field has 40 fields of numbers like that: 38.00 51.00 10.00 -99.90 75.00 47.00 4.00 -99.90 69.00 121.00 62.00 6.00 70.00 43.00 36.00 49.00 8.00 36.00 50.00... (1 Reply)
Discussion started by: tonet
1 Replies

2. Shell Programming and Scripting

using awk make an field as 5 digit and display

using awk convert 3 rd fileld of file as 5 digit and then display changed file. like 1 2 23445 3452 3343 3 5 6 6 ================ o/p:- 1 2 23445 3452 03343 3 5 00006 6 (1 Reply)
Discussion started by: RahulJoshi
1 Replies

3. Shell Programming and Scripting

awk sed cut? to rearrange random number of fields into 3 fields

I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want. The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies

4. Shell Programming and Scripting

Awk numeric range match only one digit?

Hello, I have a text file with lines that look like this: 1974 12 27 -0.72743 -1.0169 2 1.25029 1974 12 28 -0.4958 -0.72926 2 0.881839 1974 12 29 -0.26331 -0.53426 2 0.595623 1974 12 30 7.71432E-02 -0.71887 3 0.723001 1974 12 31 0.187789 -1.07114 3 1.08748 1975 1 1 0.349933 -1.02217... (2 Replies)
Discussion started by: meridionaljet
2 Replies

5. Shell Programming and Scripting

awk length of digit and print at most right digit

Have columns with digits and strings like: input.txt 3840 3841 3842 Dav Thun Tax Cahn 146; Dav. 3855 3853 3861 3862 Dav Thun Tax 2780 Karl VI., 3873 3872 3872 Dav Thun Tax 3894 3893 3897 3899 Dav Thun Tax 403; Thun 282. 3958 3959 3960 Dav Thun Tax 3972 3972 3972 3975 Dav Thun Tax... (8 Replies)
Discussion started by: sdf
8 Replies

6. Shell Programming and Scripting

Problem with awk double digit fields

Hello Everyone, This 10th field is giving too much problem in AWK. How do i overcome ? pls suggest Thanks! cat /tmp/data_rank| awk 'BEGIN{ print "HT No" "," "Name" "," "Maths" "," "Physics" "," "Chemistry" "," "Total" "," "Gender" "," "University" "," "RANK Global" "," "Rank... (2 Replies)
Discussion started by: InduInduIndu
2 Replies

7. Shell Programming and Scripting

Join fields comparing 4 fields using awk

Hi All, I am looking for an awk script to do the following Join the fields together only if the first 4 fields are same. Can it be done with join function in awk?? a,b,c,d,8,,, a,b,c,d,,7,, a,b,c,d,,,9, a,b,p,e,8,,, a.b,p,e,,9,, a,b,p,z,,,,9 a,b,p,z,,8,, desired output: ... (1 Reply)
Discussion started by: aksijain
1 Replies

8. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

9. Shell Programming and Scripting

awk - compare 1st 15 fields of record with 20 fields

I'm trying to compare 2 files for differences in a selct number of fields. When differnces are found it will write the whole record of the second file including appending '|C' out to a delta file. Each record will have 20 fields, but only want to do comparison of 1st 15 fields. The 1st field of... (7 Replies)
Discussion started by: sljnk
7 Replies

10. Shell Programming and Scripting

awk sort based on difference of fields and print all fields

Hi I have a file as below <field1> <field2> <field3> ... <field_num1> <field_num2> Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields. I tried this and it doesn't sort on the difference field .. Appreciate your help. cat... (9 Replies)
Discussion started by: newstart
9 Replies
FMCS(1) 							   User Commands							   FMCS(1)

NAME
fmcs - fmcs DESCRIPTION
usage: fmcs [-h] [--maximize {atoms,bonds}] [--min-num-atoms INT] [--compare {topology,elements,types}] [--atom-compare {any,elements,isotopes}] [--bond-compare {any,bondtypes}] [--atom-class-tag TAG] [--ring-matches-ring-only] [--complete-rings-only] [--select SELECT] [--timeout SECONDS] [--output FILENAME] [--output-format {smarts,fragment-smiles,fragment-sdf,complete-sdf}] [--output-all] [--save-atom-class-tag TAG] [--save-counts-tag TAG] [--save-atom-indices-tag TAG] [--save-smarts-tag TAG] [--save-smiles-tag TAG] [--times] [-v] [--version] filename Find the maximum common substructure of a set of structures positional arguments: filename SDF or SMILES file optional arguments: -h, --help show this help message and exit --maximize {atoms,bonds} Maximize the number of 'atoms' or 'bonds' in the MCS. (Default: bonds) --min-num-atoms INT Minimimum number of atoms in the MCS (Default: 2) --compare {topology,elements,types} Use 'topology' as a shorthand for '--atom-compare any --bond-compare any', 'elements' is '--atom-compare elements --bond-compare any', and 'types' is '--atomcompare elements --bond-compare bondtypes' (Default: types) --atom-compare {any,elements,isotopes} Specify the atom comparison method. With 'any', every atom matches every other atom. With 'elements', atoms match only if they con- tain the same element. With 'isotopes', atoms match only if they have the same isotope number; element information is ignored so [5C] and [5P] are identical. This can be used to implement user-defined atom typing. (Default: elements) --bond-compare {any,bondtypes} Specify the bond comparison method. With 'any', every bond matches every other bond. With 'bondtypes', bonds are the same only if their bond types are the same. (Default: bondtypes) --atom-class-tag TAG Use atom class assignments from the field 'TAG'. The tag data must contain a space separated list of integers in the range 1-10000, one for each atom. Atoms are identical if and only if their corresponding atom classes are the same. Note that '003' and '3' are treated as identical values. (Not used by default) --ring-matches-ring-only Modify the bond comparison so that ring bonds only match ring bonds and chain bonds only match chain bonds. (Ring atoms can still match non-ring atoms.) --complete-rings-only If a bond is a ring bond in the input structures and a bond is in the MCS then the bond must also be in a ring in the MCS. Selecting this option also enables --ring-matches-ring-only. --select SELECT Select a subset of the input records to process. Example: 1-10,13,20,50- (Default: '1-', which selects all structures) --timeout SECONDS Report the best solution after running for at most 'timeout' seconds. Use 'none' for no timeout. (Default: none) --output FILENAME, -o FILENAME Write the results to FILENAME (Default: use stdout) --output-format {smarts,fragment-smiles,fragment-sdf,complete-sdf} 'smarts' writes the SMARTS pattern including the atom and bond criteria. 'fragment-smiles' writes a matching fragment as a SMILES string. 'fragment-sdf' writes a matching fragment as a SD file; see --save-atom-class for details on how atom class information is saved. 'complete-sdf' writes the entire SD file with the fragment information stored in the tag specified by --save-frag- ment-indices-tag. (Default: smarts) --output-all By default the structure output formats only show an MCS for the first input structure. If this option is enabled then an MCS for all of the structures are shown. --save-atom-class-tag TAG If atom classes are specified (via --class-tag) and the output format is 'fragment-sdf' then save the substructure atom classes to the tag TAG, in fragment atom order. By default this is the value of --atomclass-tag. --save-counts-tag TAG Save the fragment count, atom count, and bond count to the specified SD tag as space separated integers, like '1 9 8'. (The fragment count will not be larger than 1 until fmcs supports disconnected MCSes.) --save-atom-indices-tag TAG If atom classes are specified and the output format is 'complete-sdf' then save the MCS fragment atom indices to the tag TAG, in MCS order. (Default: mcs-atomindices) --save-smarts-tag TAG Save the MCS SMARTS to the specified SD tag. Uses '-' if there is no MCS --save-smiles-tag TAG Save the fragment SMILES to the specified SD tag. Uses '-' if there is no MCS --times Print timing information to stderr -v, --verbose Print progress statistics to stderr. Use twice for higher verbosity. --version For more details on these options, see https://bitbucket.org/dalke/fmcs/ fmcs 1.0 June 2012 FMCS(1)
All times are GMT -4. The time now is 10:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy