Sponsored Content
Top Forums Shell Programming and Scripting Print only lines where fields concatenated match strings Post 302757737 by Ophiuchus on Friday 18th of January 2013 01:32:56 AM
Old 01-18-2013
Print only lines where fields concatenated match strings

Hello everyone,

Maybe somebody could help me with an awk script.

I have this input (field separator is comma ","):
Code:
547894982,M|N|J,U|Q|P,98,101,0,1,1
234900027,M|N|J,U|Q|P,98,101,0,1,1
234900023,M|N|J,U|Q|P,98,54,3,1,1
234900028,M|H|J,S|Q|P,98,101,0,1,1
234900030,M|N|J,U|F|P,98,101,0,1,1
547894932,M|H|J,U|Q|P,98,101,0,1,1
547894900,M|N|J,U|Q|P,98,101,0,1,1
547894995,M|T|J,U|Q|P,98,101,0,1,1
547894977,M|N|J,U|Q|P,0,101,0,1,1
300888261,R|N|J,U|Q|P,98,101,0,1,1

If the resulting string of concatenate fields from field2 to last field is different to the following strings:
M|N|JU|Q|P98101011
M|H|JU|Q|P98101011
M|H|JS|Q|P98101011

Then print those lines, so the output should be:
Code:
234900023,M|N|J,U|Q|P,98,54,3,1,1,Different
234900030,M|N|J,U|F|P,98,101,0,1,1,Different
547894995,M|T|J,U|Q|P,98,101,0,1,1,Different
547894977,M|N|J,U|Q|P,0,101,0,1,1,Different
300888261,R|N|J,U|Q|P,98,101,0,1,1,Different

I hope the explanation is good enough.

Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strings from one file which exactly match to the 1st column of other file and then print lines.

Hi, I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines). ################################# huge_file.txt a a ab b ################################## small_file.txt a 1.5 b 2.5 ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies

2. Shell Programming and Scripting

Splitting Concatenated Words With Largest Strings First

hello, I had posted earlier help for a script for splitting concatenated words . The script was supposed to read words from a master file and split concatenated words in the slave/input file. Thanks to the help I got, the following script which works very well was posted. It detects residues by... (14 Replies)
Discussion started by: gimley
14 Replies

3. Shell Programming and Scripting

awk strings search + print next column after match

Hi, I have a file filled with search strings which have a blank in between and look like this: S. g. Ehr. o. Jg. v. d. Chijs g. Ehr. Now i would like to search for the strings and it also shall return the next column after the match. awk -v FILE="search_strings.txt" 'BEGIN {... (10 Replies)
Discussion started by: sdf
10 Replies

4. Shell Programming and Scripting

Print strings that match pattern with awk

I have a file with many lines which contain strings like .. etc. But with no rule regarding field separators or anything else. I want to print ONLY THE STRING from each line , not the entire line !!! For example from the lines : Flow on service executed with success in . Performances... (5 Replies)
Discussion started by: black_fender
5 Replies

5. Shell Programming and Scripting

Returning two lines if they both match strings

Hi I have a problem where I have a large amount of files that I need to scan and return a line and its following line, but only when the following line begins with a string. String one - line one must begin with 'Bill' String two - line two must begin with 'Jones'. If these two... (7 Replies)
Discussion started by: majormajormajor
7 Replies

6. UNIX for Dummies Questions & Answers

awk - (URGENT!) Print lines sort and move lines if match found

URGENT HELP IS NEEDED!! I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but - Currently, script is not printing lines to File3.txt in order. - Also the matching lines are not moving out of File1.txt ... (1 Reply)
Discussion started by: High-T
1 Replies

7. Shell Programming and Scripting

Match the value & print lines from the match

Hello, I have a file contains two columns. I need to print the lines after “xxx” so i'm trying to match "xxx" & cut the lines after that. I'm trying with the grep & cut command, if there any simple way to extract this please help me. Sample file : name id AAA 123 AAB 124 AAC 125... (4 Replies)
Discussion started by: Shenbaga.d
4 Replies

8. Shell Programming and Scripting

awk to print fields that match using conditions and a default value for non-matching in two files

Trying to use awk to match the contents of each line in file1 with $5 in file2. Both files are tab-delimited and there may be a space or special character in the name being matched in file2, for example in file1 the name is BRCA1 but in file2 the name is BRCA 1 or in file1 name is BCR but in file2... (6 Replies)
Discussion started by: cmccabe
6 Replies

9. Shell Programming and Scripting

awk to combine lines if fields match in lines

In the awk below, what I am attempting to do is check each line in the tab-delimeted input, which has ~20 lines in it, for a keyword SVTYPE=Fusion. If the keyword is found I am splitting $3 using the . (dot) and reading the portion before and after the dot in an array a. If it does have that... (12 Replies)
Discussion started by: cmccabe
12 Replies

10. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies
vzubc(8)							    Containers								  vzubc(8)

NAME
vzubc - show User Beancounters in a human-readable format SYNOPSIS
vzubc [option ...] [CTID ...] DESCRIPTION
This utility aims to show current values for User Beancounter in a human-readable format. Values that are in pages are converted into bytes, then long values are converted into kilo-, mega- gigabytes etc. For held and maxheld, it shows how close the values are to the bar- rier and to the limit. Zero and unlimited values are shown as -. One or several CTIDs can be specified to limit the output to the given containers. Each CTID can be either a name or a numeric ID. Note that names can only be used if there is a container on the system with that name (vzlist -o ctid name command is used for name to ID con- version). Unknown CTIDs are ignored. The utility can also be used from inside the container, in this case it only shows the values for that container (and it doesn't make sense to specify CTID argument). OPTIONS
-w, --watch Watch mode: run itself under watch(1), redisplaying the output every 2 seconds (by default) until interrupted by Ctrl-C. -wd Make watch(1) highlight the differences between current and previous output (corresponds to watch -d option). -wn time Refresh interval for watch(1), in seconds (corresponds to watch -n time). -q, --quiet Quiet mode. In this mode, vzubc only shows beancounters with fails and those with held/maxheld values close to limits. -qh ratio Quiet threshold for held to limit ratio. Default is 0.5 (50%). -qm ratio Quiet threshold for maxheld to limit ratio. Default is 0.8 (80%). -r, --relative Relative mode: for fail counters, instead of showing the absolute value, calculate the difference from the previous run. This mode is denoted by a + sign before the FAIL column header. -rd dir Set a directory for saving fail counters to dir (default is /tmp/vzubc.store). -rc Clear all saved fail counter data. -i, --incremental Incremental mode. Shows an additional column with a difference in held value from the previous run. This option also affects quiet mode: all lines with changed held values are shown. Held data is saved to the same directory as fail counter data. -id dir A synonym for -rd. -ic Clear all saved held data. -c, --color Enable color highlighting. Not compatible with --watch. Same thresholds as for quiet mode are used to highlight "more important" lines, plus the lines with non-zero fail counters are highlighted. -f | --file filename Read User Beancounters from filename. By default this is /proc/bc/resources or, if that one is not available, /proc/user_beancoun- ters. Use - to read from standard input. EXAMPLES
vzubc 101 web dns Show all beancounters for CTID 101 and for CTs named web and dns. vzubc -w -wd -wn 10 101 Display beancounters for CT 101 every 10 seconds, highlighting the changes. Interrupt with Control-C. vzubc -q -c Show beancounters with held or maxheld close to limits, plus those with non-zero fail counters, with colors. vzubc -q -qh 0.8 -qm 1 Show beancounters with held value equal to or more than 80% of a limit, and/or with maxheld value equal or more than a limit, plus those with non-zero fail counters. vzubc -w -q -r Display beancounters with held and maxheld close to limits, plus those with increasing fail counters. vzubc -r -q -qh 2 -qm 2 Only show beancounters with increased (since the last run) fail counters. vzubc -rc -ic Show all beancounters, and clear all saved data for relative and incremental mode (i.e. saved values for fail counter and held). FILES
/proc/bc/resources /proc/user_beancounters /tmp/vzubc.store/ubc.* EXIT STATUS
Returns 0 upon successful execution, 1 otherwise. SEE ALSO
watch(1), vzlist(8), vzmemcheck(8), vzcfgvalidate(8), http://wiki.openvz.org/UBC. LICENSE
Copyright (C) 2011, Parallels, Inc. Licensed under GNU GPL. OpenVZ 3 Jun 2011 vzubc(8)
All times are GMT -4. The time now is 06:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy