Sponsored Content
Top Forums UNIX for Dummies Questions & Answers awk - Print lines if only matching key is found Post 302933719 by RudiC on Monday 2nd of February 2015 03:01:56 AM
Old 02-02-2015
Using the term URGENT, esp. in bold red, is deprecated and sort of risky in these fora. Try to avoid it in the fututre.

If I remember correctly, you have been supplied with solutions to very similar problems in various threads in the recent past which you tried to condense into your script. So I think you're not too far away. Why don't you sit back and stare a while at your code snippet? The solution will jump to your eyes. (Little hint: Look at your if (key in a) command and what you are printing there...) And, you might want to add an else branch to print the non-matching records.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AIX equivalent to GNU grep's -B and -A [print lines after or before matching lines]

Hi folks I am not allowed to install GNU grep on AIX. Here my code excerpt: grep_fatal () { /usr/sfw/bin/gegrep -B4 -A2 "FATAL|QUEUE|SIGHUP" } Howto the same on AIX based machine? from manual GNU grep ‘--after-context=num’ Print num lines of trailing context after... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

2. Shell Programming and Scripting

Print lines matching value(s) in other file using awk

Hi, I have two comma separated files. I would like to see field 1 value of File1 exact match in field 2 of File2. If the value matches, then it should print matched lines from File2. I have achieved the results using cut, paste and egrep -f but I would like to use awk as it is efficient way and... (7 Replies)
Discussion started by: SBC
7 Replies

3. Shell Programming and Scripting

print lines from a file containing key word

i have a file containing over 1 million records,and i want to print about 300,000 line containing a some specific words. file has content. eg 1,rrt,234 3,fgt,678 4,crf,456 5,cde,drt 6,cfg,123 and i want to print the line with the word fgt,crf this is just an example,my file is so... (2 Replies)
Discussion started by: tomjones
2 Replies

4. Shell Programming and Scripting

awk print non matching lines based on column

My item was not answered on previous thread as code given did not work I wanted to print records from file2 where comparing column 1 and 16 for both files find rows where column 16 in file 1 does not match column 16 in file 2 Here was CODE give to issue ~/unix.com$ cat f1... (0 Replies)
Discussion started by: sigh2010
0 Replies

5. Shell Programming and Scripting

awk to print all lines after a pattern is found

Is there a way with aw to print all lines after a string is found There is a file like this ....... ........ 2012/19/11 :11.58 PM some data lne no date 2012/19/11 :11.59 PM some other data 2012/20/11 :12.00 AM some other data some line without dates some more lines without dates... (8 Replies)
Discussion started by: swayam123
8 Replies

6. Shell Programming and Scripting

Compare file1 for matching line in file2 and print the difference in matching lines

Hello, I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Discussion started by: RasB15
2 Replies

7. Shell Programming and Scripting

How to print few lines before and after matching word is found suing grep?

Hi, here are few lines present in the logs. I want to grep on Error and print few lines before and after Error word is found line1 Line2 Line3 Error Line4 Line5 Line6 Line7 I want the output to be Line2 Line3 Error Line5 (1 Reply)
Discussion started by: arghadeep adity
1 Replies

8. 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

9. Shell Programming and Scripting

Find key pattern and print selected lines for each record

Hi, I need help on a complicated file that I am working on. I wanted to extract important info from a very huge file. It is space delimited file. I have hundred thousands of records in this file. An example content of the inputfile as below:- ## ID Ser402 Old; 23... (2 Replies)
Discussion started by: redse171
2 Replies

10. 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
ckport(1)						   System User's Manual: ckport 						 ckport(1)

NAME
ckport - portability analysis and security checking tool SYNOPSIS
ckport [OPTIONS]... file [file,...] DESCRIPTION
ckport is a tool to check already compiled binaries and libraries for porting and security problems. It uses objdump to read the binaries and analysis call and jump functions. This package is architecture independent and can be used on non-host architecture binaries if a objdump tool for the target architecture is installed. OPTIONS
--help -h Show this help. -- End of options, only filenames follow. --mode MODE Sets mode of operation. --db DBFILE Load database DBFILE. --db-dir DBDIR Load databases from directory DBDIR. --edit-vim Show vim command pointing to location of problem. --conf KEY=VAL Set config key KEY to value VAL. --warn-mode MODE Set mode for printing of warnings. --warn PT Warn about problems of type PT. --nowarn PT Ignore warnings about problems of type PT. --nowarns Disable all warnings. --nosummery Disable summery. --summery Enable summery. --summery-on-warn Only print summery if warnings has been found. --noheader Disable printing of headers. --header Enable printing of headers. --nofile-header Disable printing of headers for each file (operant). --file-header Enable printing of headers for each file (operant). --ignore PATTERN Ignore symbols matching this Perl regex pattern. --ignore-symbol SYMBOL Ignore symbol SYMBOL. --ignore-target TARGET Ignore warnings for target TARGET. --print-mode MODE Set mode of symbol printing to MODE. --print-unknown Print unknown symbols found. --print-unknown-defined Print list of unknown but defined (internal) symbols. --print-unused Print list of defined (internal) but unused symbols. --print-known Print list of known symbols. --print-pt Print list of known problem types. SEE ALSO
objdump(1). ckport April 2011 ckport(1)
All times are GMT -4. The time now is 05:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy