Sponsored Content
Top Forums Shell Programming and Scripting AWK Help ME! this easy for who know Post 302374906 by He2 on Wednesday 25th of November 2009 09:04:56 PM
Old 11-25-2009
Power AWK Help ME! this easy for who know

Friends;
I have little experience with shell and I am not able to resolve this

problem:

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

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

compare column 3 of file 2 and column 4 file 1. as in column 4 of file 1 is contained in the 2nd column 3.

eg
> Line 1 of file 1:
CRA-JJ-W980-01;2009-11-24;GigabitEthernet;0/0

> Line 1 of file 2:
CRA-JJ-W980-01;2009-11-24;0/0/0;6967

0/0/0 contains the beginning 0/0

then I would file a 3 with the following output:

File3:
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

Thank you.
 

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
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 03:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy