Sponsored Content
Top Forums Shell Programming and Scripting Matching pattern in two files and print the line Post 302863355 by khalil on Monday 14th of October 2013 03:29:45 AM
Old 10-14-2013
Matching pattern in two files and print the line

Hi,

I want to match the pattern in file1 with file2 and print the value in file2 and paste in file1
file1:

Code:
ISHO RT SR                                Major     96.46778
Drop Call Rate CS                       Critical  0.5072662
ISHO RT SR                                Major     97.754364
Active HS-DSCH MAC-d          Critical  1979.25
ISHO RT SR                                Major     97.31076

file2:
Code:
RRC Stup RNC Failures   0.1
Active HS-DSCH MAC-d    2000    
Drop Call Rate PS       0.8
ISHO RT SR    96

I want the output:
Code:
ISHO RT SR                                Major     96.4        96
Drop Call Rate PS                       Critical  0.50         0.8
ISHO RT SR                                Major     97.75      96
Active HS-DSCH MAC-d          Critical  1979.25   2000
ISHO RT SR                                Major     97.3       96

I tried grep each pattern:
Code:
grep -i 'pattern' file1 file2 ',awk '{$0}''

It's not working

Last edited by Scrutinizer; 10-14-2013 at 04:36 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

pattern matching and print with sed

Hi It is possible with sed to print a pattern within a line matching regexp? So, the line looks like : 19:00:00 blablablabla jobid 2345 <2> the regexp is "jobid 2345" and the pattern is 56434. That the code for find... (2 Replies)
Discussion started by: nymus7
2 Replies

2. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

3. Shell Programming and Scripting

I want to print next 3 lines after pattern matching.

Dear Experts, I have file called file1 in which i am greping a pattern after that i want to next 3 lines when that pattern is matched. Ex:- file1 USA UK India Africa Hello Asia Europe Australia Hello Peter Robert Jo i want to next 3 lines after matching Hello... (12 Replies)
Discussion started by: naree
12 Replies

4. Shell Programming and Scripting

print range of lines matching pattern and previous line

Hi all, on Solaris 10, I'd like to print a range of lines starting at pattern but also including the very first line before pattern. the following doesn't print the range starting at pattern and going down to the end of file: cat <my file> | sed -n -e '/<pattern>{x;p;}/' I need to include the... (1 Reply)
Discussion started by: siriche
1 Replies

5. UNIX for Dummies Questions & Answers

sed print matching pattern

Hi, i have data file like: START1 a b STOP c d START2 e STOP f START3 g STOP When one of the START<count> variable is passed, i should print all lines matching this until the first 'STOP' for example if 'START2' is provided for match, i should get the result as: START2 (1 Reply)
Discussion started by: ysrini
1 Replies

6. Shell Programming and Scripting

How to print all the lines after pattern matching?

I have a file that contains... Number -------------------- 1 2 3 4 i want to print all the numbers after the hyphen ... (6 Replies)
Discussion started by: ankitknit
6 Replies

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

8. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

9. Shell Programming and Scripting

Print lines after matching two pattern

would like to print everything after matching two patterns AAA and BBB. output : CCC ZZZ sample data : AAA BBB CCC ZZZ (4 Replies)
Discussion started by: jhonnyrip
4 Replies

10. UNIX for Beginners Questions & Answers

Print 2 matching pattern

How to a first 3 lines lines that matches 1st pattern and 1 line that matches 2nd line. Sample.txt Line 1: /*--- ABC_BA_ABCABC -----*/ Line 2: Line 3: insert_job: ABC_BA_ABCABC job_type: BOX Line 4: blah blah Line 5: max_run_alarm: 5 Line 6: blah blah ---- ----- Line 20: /*---... (4 Replies)
Discussion started by: bobbygsk
4 Replies
hpialarms(1)							      OpenHPI							      hpialarms(1)

NAME
hpialarms - A openhpi sample application that shows "Alarm Control" management instruments SYNOPSIS
hpialarms [-a -b -c -i -m -n -p -o -x] DESCRIPTION
hpialarms walks the RPT (Resource Present Table) for resouces that have "Alarm Control" management instruments (SAHPI_CTRL_LED). OPTIONS
-c1 sets Critical Alarm on -c0 sets Critical Alarm off -m1 sets Major Alarm on -m0 sets Major Alarm off -n1 sets Minor Alarm on -n0 sets Minor Alarm off -p1 sets Power Alarm on -p0 sets Power Alarm off -i5 sets Chassis ID on for 5 sec -i0 sets Chassis ID off -a1 sets Disk A fault on -a0 sets Disk A fault off -b1 sets Disk B fault on -b0 sets Disk B fault off -d[byte] sets raw Alarm byte -o sets all Alarms off -x show eXtra debug messages SAMPLE OUTPUT
hpialarmpanel ver 0.6 RptInfo: UpdateCount = 5, UpdateTime = 8a2dc6c0 rptentry[0] resourceid=1 tag: Mullins RDR[45]: ctltype=2:1 oem=0 Chassis Identify Control RDR[48]: ctltype=0:1 oem=10 Front Panel Power Alarm LED state = off RDR[51]: ctltype=0:1 oem=13 Front Panel Minor Alarm LED state = ON RDR[46]: ctltype=0:0 oem=0 Cold Reset Control RDR[49]: ctltype=0:1 oem=11 Front Panel Critical Alarm LED state = off RDR[50]: ctltype=0:1 oem=12 Front Panel Major Alarm LED state = off SEE ALSO
AUTHORS
Authors of this man page: Peter D Phan (pdphan@users.sourceforge.net) 2.14.1 2009-11-23 hpialarms(1)
All times are GMT -4. The time now is 10:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy