Sponsored Content
Full Discussion: awk colon separated items
Top Forums UNIX for Dummies Questions & Answers awk colon separated items Post 302968822 by janshamsani on Tuesday 15th of March 2016 12:13:17 AM
Old 03-15-2016
awk colon separated items

Hi,

I need to filter my data based on items in column 23. Column 1 until column 23 are tab separated. This is how column 23 looks like:

PRIMARY=<0/1:504:499,5:.:.:.:0.01:1:15:.>

I want to extract lines if items 7 (separated by : ) in column 23 are more than 0.25 . In example above , item $7 is 0.01 .

Previously, I just need to count items that pass my criteria . I used this code and it worked perfectly .

Code:
awk -F"\t" 'NR>1 {split($23,a,":"); count[a[7]]++} END {for (i in count) if(i>0.25) sum +=count[i]; print sum}' file.tsv


Now , I need to extract information in all columns too. So i tried to modify the code but I did not work.

Code:
awk -F"\t" 'NR>1 {split($23,a,":"); count[a[7]]++} END {for (i in count) if(i>0.25) print $0}' file.tsv

The output that I want would look the same as my input file, but only with lines that pass the filter.

I have attached the sample input file
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

two lines into one colon separated line...

Does anyone know how to get these two output lines into one colon ':' separated line with some unix command? Maybe nawk. I've tried to read the nawk and awk man pages but I don't get it right. Are these commands the one to use? Output from find command: # /sw/tools/matlab/7.0.1/man... (2 Replies)
Discussion started by: tonlu
2 Replies

2. UNIX for Dummies Questions & Answers

Multiple field separators in awk? (First a space, then a colon)

How do I deal with extracting a portion of a record when multiple field separators are involved. Let's say I have: Mike Harrington;(555) 555-5555:250:100:175 Christian Dobbins;(555) 555-2358:155:90:201 Susan Dalsass;(555) 555-6279:250:60:50 Archie McNichol;(555) 555-1348:250:100:175 Jody... (3 Replies)
Discussion started by: doubleminus
3 Replies

3. Shell Programming and Scripting

awk between items including items

OS=HP-UX ksh The following works, except I want to include the <start> and <end> in the output. awk -F '<start>' 'BEGIN{RS="<end>"; OFS="\n"; ORS=""} {print $2} somefile.log' The following work in bash but not in ksh sed -n '/^<start>/,/^<end>/{/LABEL$/!p}' somefile.log (4 Replies)
Discussion started by: Ikon
4 Replies

4. Shell Programming and Scripting

Running multiple commands stored as a semi-colon separated string

Hi, Is there a way in Korn Shell that I can run multiple commands stored as a semi-colon separated string, e.g., # vs="echo a; echo b;" # $vs a; echo b; I want to be able to store commands in a variable, then run all of it once and pipe the whole output to another program without using... (2 Replies)
Discussion started by: svhyd
2 Replies

5. Shell Programming and Scripting

Colon in awk script output

I'm using AIX 5.3 and running a awk replace to modify data as follows: echo 1234: 1234 123 123 444 555 666 7777 | awk '/^:/{split($2,N);n=N} {n=$1} {sub(n,n+10000000)}1' 10001234 1234 123 123 444 555 666 7777 dumb question.. how do I get the colon back in, so it outputs 10001234: 1234... (4 Replies)
Discussion started by: say170
4 Replies

6. Shell Programming and Scripting

How to sort a column in UNIX that is colon separated ":" ?

Experts, how to sort this fields with numerical order : -How to use the sort command in this case, I was thinking with -k but it is not working, lan5000 lan5000:1 lan5000:10 lan5000:11 lan5000:12 lan5000:13 lan5000:14 lan5000:15 lan5000:16 lan5000:17 ... (6 Replies)
Discussion started by: rveri
6 Replies

7. Shell Programming and Scripting

awk :help to parse a file to change to separated by colon ":"

Hi experts , I am trying to get the below output: file : 0/6/4/1 0x0019503C2E26 5 UP lan5 snap5 1 ETHER Yes 224 0/6/4/0 0x0019503C2E25 6 UP lan6 snap6 2 ETHER Yes 224 0/2/1/0 0x0019503E6900 0 UP lan0 snap0 3 ETHER Yes 224... (8 Replies)
Discussion started by: rveri
8 Replies

8. Homework & Coursework Questions

C++ Attempting to modify this function to read from a (;) semi-colon-separated file

After some thought. I am uncomfortable issuing my professors name where, there may be unintended side effects from any negative responses/feedback. Willing to re post if I can omit school / professor publicly, but can message moderator for validation? I am here for knowledge and understanding,... (1 Reply)
Discussion started by: briandanielz
1 Replies

9. Shell Programming and Scripting

awk does not find ids with semi-colon in the name

I am using awk to search $5 of the "input" file using the "list" file as the search criteria. So if the id in line 1 of "list" is found in "search" then it is counted in the ids found. However, if the line in "list" is not found in "search", then it is outputted as is missing. The awk below runs... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. Shell Programming and Scripting

awk unique count of partial match with semi-colon

Trying to get the unique count of the below input, but if the text in beginning of $5 is a partial match to another line in the file then it is not unique. awk awk '!seen++ {n++} END {print n}' input 7 input chr1 159174749 159174770 chr1:159174749-159174770 ACKR1 chr1 ... (2 Replies)
Discussion started by: cmccabe
2 Replies
TBL(1)							      General Commands Manual							    TBL(1)

NAME
tbl - format tables for nroff or troff SYNOPSIS
tbl [ file ... ] DESCRIPTION
Tbl is a preprocessor for formatting tables for nroff or troff(1). The input files are copied to the standard output, except for segments of the form .TS options ; format . data .T& format . data . . . .TE which describe tables and are replaced by troff requests to lay out the tables. If no arguments are given, tbl reads the standard input. The (optional) options line is terminated by a semicolon and contains one or more of center center the table; default is left-adjust expand make table as wide as current line length box doublebox enclose the table in a box or double box allbox enclose every item in a box tab(x) use x to separate input items; default is tab linesize(n) set rules in n-point type delim(xy) recognize x and y as eqn(1) delimiters Each line, except the last, of the obligatory format describes one row of the table. The last line describes all rows until the next .T&, where the format changes, or the end of the table at .TE. A format is specified by key letters, one per column, either upper or lower case: L Left justify: the default for columns without format keys. R Right justify. C Center. N Numeric: align at decimal point (inferred for integers) or at S Span: extend previous column across this one. A Alphabetic: left-aligned within column, widest item centered, indented relative to L rows. ^ Vertical span: continue item from previous row into this row. - Draw a horizontal rule in this column. = Draw a double horizontal rule in this column. Key letters may be followed by modifiers, also either case: | Draw vertical rule between columns. || Draw a double vertical rule between columns. n Gap between column is n ens wide. Default is 3. Ffont Use specified font. B and I mean FB and FI. T Begin vertically-spanned item at top row of range; default is vertical centering (with Pn Use point size n. Vn Use n-point vertical spacing in text block; signed n means relative change. W(n) Column width as a troff width specification. Parens are optional if n is a simple integer. E Equalize the widths of all columns marked E. Each line of data becomes one row of the table; tabs separate items. Lines beginning with are troff requests. Certain special data items are recognized: _ Draw a horizontal rule in this column. = Draw a double horizontal rule in this column. A data line consisting of a single or draws the rule across the whole table. \_ Draw a rule only as wide as the contents of the column. Rx Repeat character x across the column. ^ Span the previous item in this column down into this row. T{ The item is a text block to be separately formatted by troff and placed in the table. The block continues to the next line begin- ning with T}. The remainder of the data line follows at that point. When it is used in a pipeline with eqn, the tbl command should be first, to minimize the volume of data passed through pipes. EXAMPLES
Let <tab> represent a tab (which should be typed as a genuine tab). .TS c s s c c s c c c l n n. Household Population Town<tab>Households <tab>Number<tab>Size Bedminster<tab>789<tab>3.26 Bernards Twp.<tab>3087<tab>3.74 Bernardsville<tab>2018<tab>3.30 .TE Household Population Town Households Number Size Bedminster 789 3.26 Bernards Twp. 3087 3.74 Bernardsville 2018 3.30 SOURCE
/sys/src/cmd/tbl SEE ALSO
troff(1), eqn(1), doctype(1) M. E. Lesk and L. L. Cherry, ``TBL--a Program to Format Tables'', Unix Research System Programmer's Manual, Tenth Edition, Volume 2. TBL(1)
All times are GMT -4. The time now is 11:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy