Formatting The Output Files & Matching Keys


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting The Output Files & Matching Keys
# 1  
Old 10-20-2014
Formatting The Output Files & Matching Keys

I have the following 2 output files, one contain the standard output after i decrypt the encrypted file and another keys listed from the gpg trust db,

Provider File:
Code:
gpg: encrypted with 2048-bit RSA key, ID 96301328, created 2014-04-29
      "JKL <400@abc.com>"
gpg: encrypted with 2048-bit ELG-E key, ID ECB614CF, created 2002-02-06
      "GHI <300@abc.com>"
gpg: encrypted with 2048-bit ELG-E key, ID 1EB07C50, created 2014-02-20
      "ABC <100@abc.com>"
gpg: WARNING: message was not integrity protected


GPG Public Keys:
Code:
pub   1024D/17CD2890 2014-02-20
uid                  ABC <100@abc.com>
sub   2048g/1EB07C50 2014-02-20

pub   2048D/8911CBCA 2014-04-03
uid                  DEF <200@abc.com>
sub   2048g/F0E4D9C3 2014-04-03

pub   1024D/CB26F4C3 2002-02-06
uid                  GHI <300@abc.com>
sub   2048g/ECB614CF 2002-02-06

pub   2048R/547A8D75 2014-04-29
uid                  JKL <400@abc.com>
sub   2048R/96301328 2014-04-29

My requirements
1) After i decrypt the file i need to make sure there are three keys embedded or used to encrypt the file, i have to get the count from the file decryption output as shown in "Provider File" excerpt above.
2) I have to search for appropriate UID's and take the corresponding values 96301328,ECB614CF,1EB07C50 from "Provider File" and match those values with "GPG Public Keys" file and email out which key is different and associated email id.

For 1, i have following snippet awk -F"[<>]" '/@/ {L++ ; print $2} END{print L+0}' from a friend but how do i supress the email id's and just print only count?
For 2, I am still working on it?

Appreciate your inputs please help.

Last edited by Ariean; 10-20-2014 at 03:09 PM..
# 2  
Old 10-20-2014
This sounds a lot like homework... I mean the fix to your friend's awk is trivial. Look at what happens after L++ (remove it)
# 3  
Old 10-20-2014
Using the small sample base, this might work:
Code:
awk 'gsub(/ *ID */,""){T[$2];print $2;next} gsub(/^uid */,"") {UID=$0} {for (i in T) if ($0~i) print UID} ' FS=, file1 file2
96301328
ECB614CF
1EB07C50
ABC <100@abc.com>
GHI <300@abc.com>
JKL <400@abc.com>

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies

2. Shell Programming and Scripting

Formatting output

I have the output like below: DEV#: 9 DEVICE NAME: hdisk9 TYPE: 1750500 ALGORITHM: Load Balance SERIAL: 68173531021 ========================================================================== Path# Adapter/Path Name State Mode Select Errors 0 ... (4 Replies)
Discussion started by: Daniel Gate
4 Replies

3. Shell Programming and Scripting

awk help: Match data fields from 2 files & output results from both into 1 file

I need to take 2 input files and create 1 output based on matches from each file. I am looking to match field #1 in both files (Userid) and create an output file that will be a combination of fields from both file1 and file2 if there are any differences in the fields 2,3,4,5,or 6. Below is an... (5 Replies)
Discussion started by: ambroze
5 Replies

4. UNIX for Dummies Questions & Answers

Formatting df output

Hi all, Can anyone please suggest how best to handle output from running df where some of the information for a volume/filesystem spread over two lines? Some of my volume/filesytem are NFS mounted and when I run a df, the information is spread over the two lines instead of the usual norm... (4 Replies)
Discussion started by: newbie_01
4 Replies

5. Shell Programming and Scripting

How to combine 2 files and output the unique & difference?

Hi Guys, I have two input files and I want to combine them and get the unique values and differences and put them into one file. See below desired output file. Inputfile1: 1111111 2222222 3333333 7860068 7860069 7860071 7860072 Inputfile2: 4444444 (4 Replies)
Discussion started by: pinpe
4 Replies

6. Shell Programming and Scripting

Problem with call of Java Programm & return code handling & output to several streams.

Hello Everybody, thanks in advance for spending some time in my problem. My problem is this: I want to call a java-Programm out of my shell skript, check if die return code is right, and split the output to the normal output and into a file. The following code doesn't work right, because in... (2 Replies)
Discussion started by: danifunny
2 Replies

7. Shell Programming and Scripting

Output formatting .

below is a CPU utilization Log for ABC server. However for every 15 minutes it generates 3 CPU values(with interval of 2 sec). Host CPU CPUtotal CPU% time ABC 101.1 2 50.55 14 : 15 ABC 100.5 2 50.25 14 : 15 ABC 100.2 2 50.1 14 : 15 ABC 100.9 2 50.45 14 : 30 ABC 100.5 2 50.25 14 : 30 ABC... (5 Replies)
Discussion started by: pinga123
5 Replies

8. Shell Programming and Scripting

Output formatting

I have input file in this way John 1234 BASIC 26000 John 1234 ALLOWC 01550 John 1234 INCER 01700 John 1234 REL 20000 Debi 2345 BASIC 29000 Debi 2345 ALLOWC 01600 Debi 2345 INCR 01900 Debi 2345 REL ... (8 Replies)
Discussion started by: vakharia Mahesh
8 Replies

9. Shell Programming and Scripting

formatting output

my script is as follows cnt=`ps -ef |grep pmon|grep -v grep|awk 'END {{print NR}}'` cnt2=`ps -ef |grep tns|grep -v grep|awk 'END {{print NR}}'` if then if then rman target/ catalog recdb/recdb@recdb cmdfile report_need_backup.sql > report_need_backup.txt ... (1 Reply)
Discussion started by: swkambli
1 Replies
Login or Register to Ask a Question