Sponsored Content
Top Forums Shell Programming and Scripting AWK Help ME! this easy for who know Post 302374918 by durden_tyler on Wednesday 25th of November 2009 11:55:49 PM
Old 11-26-2009
Code:
$ 
$ cat file1
CRA-JJ-W980-01;2009-11-24;GigabitEthernet;0/0
CRA-JJ-W980-01;2009-11-24;GigabitEthernet;1/0
CRA-JJ-W980-01;2009-11-24;GigabitEthernet;3/0
CRA-JJ-W980-01;2009-11-24;GigabitEthernet;5/0
CRA-JJ-W980-01;2009-11-24;ATM;13/0           
CRA-JJ-W980-01;2009-11-24;ATM;14/0           
CRA-JJ-W980-01;2009-11-24;ATM;15/0           
$                                            
$ cat file2                                  
CRA-JJ-W980-01;2009-11-24;0/0/0;6967         
CRA-JJ-W980-01;2009-11-24;1/0/0;5035         
CRA-JJ-W980-01;2009-11-24;3/0/0;3937         
CRA-JJ-W980-01;2009-11-24;5/0/1;5745         
CRA-JJ-W980-01;2009-11-24;11/0/0;1786        
CRA-JJ-W980-01;2009-11-24;11/0/1;2376        
CRA-JJ-W980-01;2009-11-24;13/0/0;925         
CRA-JJ-W980-01;2009-11-24;13/0/1;1254        
CRA-JJ-W980-01;2009-11-24;13/0/2;772         
CRA-JJ-W980-01;2009-11-24;13/0/3;690         
CRA-JJ-W980-01;2009-11-24;14/0/0;515         
CRA-JJ-W980-01;2009-11-24;14/0/1;179         
CRA-JJ-W980-01;2009-11-24;14/0/2;860
CRA-JJ-W980-01;2009-11-24;14/0/3;677
CRA-JJ-W980-01;2009-11-24;15/0/0;806
CRA-JJ-W980-01;2009-11-24;15/0/1;98
CRA-JJ-W980-01;2009-11-24;15/0/2;894
CRA-JJ-W980-01;2009-11-24;15/0/3;353
$
$
$ ##
$ awk -F";" '{if (NR==FNR){x[$4]=$3}
>             else {split($3,s,"/");
>                   if (x[s[1]"/"s[2]]!=""){
>                     print $1";"$2";"$3";"x[s[1]"/"s[2]]
>                   }}}' file1 file2
CRA-JJ-W980-01;2009-11-24;0/0/0;GigabitEthernet
CRA-JJ-W980-01;2009-11-24;1/0/0;GigabitEthernet
CRA-JJ-W980-01;2009-11-24;3/0/0;GigabitEthernet
CRA-JJ-W980-01;2009-11-24;5/0/1;GigabitEthernet
CRA-JJ-W980-01;2009-11-24;13/0/0;ATM
CRA-JJ-W980-01;2009-11-24;13/0/1;ATM
CRA-JJ-W980-01;2009-11-24;13/0/2;ATM
CRA-JJ-W980-01;2009-11-24;13/0/3;ATM
CRA-JJ-W980-01;2009-11-24;14/0/0;ATM
CRA-JJ-W980-01;2009-11-24;14/0/1;ATM
CRA-JJ-W980-01;2009-11-24;14/0/2;ATM
CRA-JJ-W980-01;2009-11-24;14/0/3;ATM
CRA-JJ-W980-01;2009-11-24;15/0/0;ATM
CRA-JJ-W980-01;2009-11-24;15/0/1;ATM
CRA-JJ-W980-01;2009-11-24;15/0/2;ATM
CRA-JJ-W980-01;2009-11-24;15/0/3;ATM
$
$

tyler_durden
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Easy question about awk gsub

How does one escape the left bracket in awk? For example: | awk 'gsub (" I'm sure it's pretty simple, I'm just a noob. (1 Reply)
Discussion started by: TheCrunge
1 Replies

2. Shell Programming and Scripting

Easy AWK question

Ive got some output in a file that looks exactly like this: 1 ----------- 1542 1 record(s) selected. How do I just extract that 1542 and drop it into another file or (preferrably) a variable (using a ksh script) (9 Replies)
Discussion started by: rdudejr
9 Replies

3. UNIX for Dummies Questions & Answers

Need help on installing an EASY to use and easy to install command line text editor

Hi again. Sorry if it seems like I'm spamming the boards a bit, but I figured I might as well ask all the questions I need answers to at once, and hopefully at least get some. I have installed Solaris 10 on a server. The default text editors are there (vi, ex, ed, maybe others, I know emacs is... (4 Replies)
Discussion started by: EugeneG
4 Replies

4. UNIX for Dummies Questions & Answers

Newbie Help with Grep or Awk .. Easy one ...

I have this output: uniquemember=uid=315kthatch,ou=people,ou=client315,dc=paisleyhosting,dc=com and i want the output to be just this: 315kthatch I need it to be generic tho, because I have hundreds of lines of output, and the preceding numbers are not always 315. So I would need... (3 Replies)
Discussion started by: kthatch
3 Replies

5. UNIX for Dummies Questions & Answers

fun and easy awk question

I have a file called mytitles.txt containing a list of book titles I have a second file called abfile.txt containing a list of book titles (in the 3rd field) and it has author info and copyright year info as well.. I want to search mytitles.txt for a match in the 3rd field of abfiles.txt, and... (2 Replies)
Discussion started by: glev2005
2 Replies

6. Shell Programming and Scripting

awk Help: quick and easy question may be: How to use &&

Hi Guru's. I am trying to use to check if $5 is greater than 80 & if not 100, then to print $0 : awk '{ if ($5>80) && if ($5 != 100) print $0} But getting error: >bdf1|sed 's/%//g'|awk '{ if ($5>80) && if ($5 != 100) print $0}' syntax error The source line is 1. The error... (6 Replies)
Discussion started by: rveri
6 Replies

7. Shell Programming and Scripting

Couple of easy questions for experts on awk/sed

Hello Experts.. I have 3-4 C codes with Oracle SQL statements embedded. All the SQL statements starts with EXEC SQL keyword and ends with ;. I want to extract all the SQL statements out of these codes. I did awk '/^EXEC SQL/,/\;/' inputFile (I use this on all of the codes individually). That... (2 Replies)
Discussion started by: juzz4fun
2 Replies

8. Shell Programming and Scripting

awk easy question

So, I have the following code: cat testfile.txt | awk -F, '{ print $1" "$2" "$3" "$4" "$5 }' | read DOC ORG NAME echo "$DOC" echo "$ORG" echo "$NAME" My testfile.txt looks something like the following: Document Type,Project Number,Org ID,Invoice Number It will eventually be more... (14 Replies)
Discussion started by: Parrakarry
14 Replies
CPG_ZCB_ALLOC(2009-04-15)												 CPG_ZCB_ALLOC(2009-04-15)

NAME
cpg_zcb_alloc - Allocates a zero copy buffer #include <corosync/cpg.h> int cpg_zcb_alloc(cpg_handle_t handle, size_t size, void **buffer); DESCRIPTION
The cpg_zcb_alloc function will allocate a zero copy buffer for use with the cpg_zcb_mcast_joined(3) funtion. This buffer should not be used in another thread while a cpg_zcb_mcast_joined operation is taking place on the buffer. The buffer is allocated via operating system mechanisms to avoid copying in the IPC layer. The argument handle describes the handle on which the buffer will be allocated. The argument size requests a buffer of size be allocated. The buffer argument is set to the buffer address that is allocated by this operatoin. RETURN VALUE
This call returns the CPG_OK value if successful, otherwise an error is returned. ERRORS
The errors are undocumented. SEE ALSO
cpg_overview(8), cpg_initialize(3), cpg_finalize(3), cpg_fd_get(3), cpg_dispatch(3), cpg_join(3), cpg_leave(3), cpg_mcast_joined(3), cpg_membership_get(3) cpg_zcb_alloc(3) cpg_zcb_free(3) cpg_zcb_mcast_joined(3) cpg_context_get(3) cpg_context_set(3) cpg_local_get(3) Corosync Cluster Engine Programmer's Manual corosync Man Page CPG_ZCB_ALLOC(2009-04-15)
All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy