Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk do not split if condition is meet Post 303036079 by cmccabe on Thursday 13th of June 2019 04:10:43 PM
Old 06-13-2019
awk do not split if condition is meet

Trying to use awk to format the input based on the filed count being 5. Most lines are fine using the awk below, except the first two lines. I know the reason is the -1 in green and -2 in blue. But can not figure out how to not split on the - if it is followed by a digit then letter. Thank you Smilie.

input

Code:
chr9:21971208 CDKN2A c.151-1G>A p.?
chr9:21971209 CDKN2A c.151-2A>G p.?
chr5:112175216 APC c.3925G>T p.E1309*
chr5:112175363 APC c.4072G>A p.A1358T
chr5:112175390 APC c.4099C>T p.Q1367*
EGFR,,EGFR c.2240_2257delTAAGAGAAGCAACATCTC p.L747_P753delinsS,chr7:55242470_55242487delTAAGAGAAGCAACATCTC,3470,,,,

current

Code:
chr9 21971208 CDKN2A c.151 1G>A p.?
chr9 21971209 CDKN2A c.151 2A>G p.?
chr5 112175216 112175216 APC p.E1309*
chr5 112175363 112175363 APC p.A1358T
chr5 112175390 112175390 APC p.Q1367*
chr7 55242470 55242487 EGFR c.2240_2257delTAAGAGAAGCAACATCTC p.L747_P753delinsS

desired

Code:
chr9 21971208 21971208 CDKN2A c.151-1G>A p.?
chr9 21971209 21971209 CDKN2A c.151-2A>G p.?
chr5 112175216 112175216 APC p.E1309*
chr5 112175363 112175363 APC p.A1358T
chr5 112175390 112175390 APC p.Q1367*
chr7 55242470 55242487 EGFR c.2240_2257delTAAGAGAAGCAACATCTC p.L747_P753delinsS

awk

Code:
awk -F'[ :_-]' 'NF==5{$4=$3;$3=$2} {$1=$1} 1' input


Last edited by cmccabe; 06-13-2019 at 07:24 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to split a file based on the condition

I have the file with the records like 4234234 US phone 3244234 US cup 2342342 CA phone 8947234 US phone 2389472 CA cup 2348972 US maps 3894234 CA phone I want the records with (US,phone) as record to be in one file, (Us, cup) in another file and (CA,cup) to be in another I mean all... (12 Replies)
Discussion started by: superprogrammer
12 Replies

2. Shell Programming and Scripting

How to split the String based on condition?

hi , I have a String str="/opt/ibm/lotus/ibw/latest" or ="/opt/lotus/ibw/latest" this value is dynamic..I want to split this string into 2 strings 1. /opt/ibm/lotus(/opt/lotus) this string must ends with "lotus" 2./ibw/latest can any body help me on this? Regards, sankar (2 Replies)
Discussion started by: sankar reddy
2 Replies

3. Shell Programming and Scripting

split file with condition

$ cat file H1:12:90 k:12:b n:22:i k:54:b k:42:b s:48:s a:41:b t:18:n c:77:a I am trying to split above file based on $2 such that if $2 is rounded to nearest 10's multiple (e.g. 10,20,30 etc), each sub file should contain 3 multiples and so on (also I want to keep header i.e. NR==1, in... (6 Replies)
Discussion started by: uwork72
6 Replies

4. Shell Programming and Scripting

Printing records which meet condition using awk

Below is the code nawk -F"|" 'tolower($1) ~ "abc" |"" {if (tolower($2) ~"abc"|"") print$0}' file I want the records from file whose 1st and 2nd field should be either "abc" or "null" I tried but its giving error. Appreciate help (2 Replies)
Discussion started by: pinnacle
2 Replies

5. Shell Programming and Scripting

how to use split command in unix shell with a condition

Hi all, I have a file which I want to split into several files based on a condition. This files has several records. I want one record per file. Each record ends with a //. So, I want to separate files based on this condition. I want split files to be named with the name across the field ID (for... (2 Replies)
Discussion started by: kaav06
2 Replies

6. Shell Programming and Scripting

How to Split File to 2 depending on condition?

Hi , cat myfile.txt ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.22.11 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.2.50 ! 3100.2.22.11 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 ! 3100.2.30.33 ! 3100.2.4.1 ! ! 3100.2.0.5 ! 3100.2.22.4 !... (6 Replies)
Discussion started by: OTNA
6 Replies

7. Shell Programming and Scripting

awk to print matching lines in files that meet critera

In the tab delimited files below I am trying to match $2 in file1 to $2 of file2. If a match is found the awk checks $3 of file2 and if it is greater than 40% and $4 of file2 is greater than 49, the line in file1 is printed. In the desired output line3 of file1 is not printed because $3 off file2... (9 Replies)
Discussion started by: cmccabe
9 Replies

8. Shell Programming and Scripting

awk to capture lines that meet either condition

I am trying to modify and understand an awk written by @Scrutinizer The below awk will filter a list of 30,000 lines in the tab-delimited file. What I am having trouble with is adding a condition to SVTYPE=CNV that will only print that line if CI=,0.95: portion in blue in file is <1.9. The... (2 Replies)
Discussion started by: cmccabe
2 Replies

9. Shell Programming and Scripting

Print header and lines that meet both conditions in awk

In the awk below I am trying to print only the header lines starting with # or ## and the lines that $7 is PASS and AF= is less than 5%. The awk does execute but returns an empty file and I am not sure what I am doing wrong. Thank you. file ... (0 Replies)
Discussion started by: cmccabe
0 Replies

10. Shell Programming and Scripting

awk to print lines that meet conditions and have value in another file

I am trying to use awk to print lines that satisfy either of the two conditions below: condition 1: $2 equals CNV and the split of $3, the value in red, is greater than or equal to 4. ---- this is a or so I think condition 2: $2 equals CNV and the split of $3, the value in red --- this is a... (4 Replies)
Discussion started by: cmccabe
4 Replies
NEWAPC(8)						      Network UPS Tools (NUT)							 NEWAPC(8)

NAME
newapc - Driver for American Power Conversion Smart Protocol UPS equipment NOTE
This man page only documents the hardware-specific features of the newapc driver. For information about the core driver, see nutupsdrv(8). SUPPORTED HARDWARE
newapc should recognize all recent APC models that use a serial protocol at 2400 bps. This is primarily the Smart-UPS, Matrix-UPS and Back-UPS Pro lines. Older APC models may work better with the apcsmart driver. The driver attempts to support every bell and whistle of the APC reporting interface, whether or not this is strictly sensible. Some older hardware may only report a handful of variables. This is usually not a bug - they just don't support anything else. CABLING
This driver expects to see a 940-0024C cable or a clone by default. You can switch to the 940-0095B dual-mode cable support with the cable= definition described below. If your 940-0024C cable is broken or missing, use this diagram to build a clone: http://www.exploits.org/nut/library/cables/940-0024C.jpg EXTRA ARGUMENTS
This driver supports the following optional settings in the ups.conf(5): cable=940-0095B Configure the serial port for the APC 940-0095B dual-mode cable. sdtype=num Use shutdown type num, according to this table: 0: soft shutdown or powerdown, depending on battery status 1: soft shutdown followed by powerdown 2: instant power off 3: power off with grace period Modes 0 and 1 will power up the load when power returns. Modes 2 and 3 will keep the load turned off when the power returns. BUGS
Some older APC UPS models return bogus data in the status register during a front panel test. This is usually detected and discarded, but some other unexpected values have occasionally slipped through. AUTHOR
Nigel Metheringham <Nigel.Metheringham@Intechnology.co.uk> (drawing heavily on the apcsmart driver by Russell Kroll). SEE ALSO
The core driver: nutupsdrv(8) The apcsmart driver: apcsmart(8) Internet resources: The NUT (Network UPS Tools) home page: http://www.exploits.org/nut/ NUT mailing list archives and information: http://lists.exploits.org/ Tue Oct 22 2002 NEWAPC(8)
All times are GMT -4. The time now is 09:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy