parsing using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parsing using shell script
# 1  
Old 05-13-2011
parsing using shell script

I have a file parameters.txt which contains
Code:
151524
151525

I have another file OID.csv which contains
Code:
NE        Version                    Object Type     ID             SDK param name               Object OID
test1       Start: 4.2 End: 4.2    pan                       151524        speed                 .1.3.6.1.2.1.2.2.1.5
jhhu       Start: 4.2 End: 4.2     pan                       151525        management type       .1.3.6.1.2.1.2.2.1.3

No i need to get the parameter from parameters.txt file and search for the it in csv file, when matched then take the oid for the matched parameter and write to another file which should be like this
Code:
151524 .1.3.6.1.2.1.2.2.1.5
151525 .1.3.6.1.2.1.2.2.1.3


Last edited by Franklin52; 05-13-2011 at 04:32 AM.. Reason: Please use code tags
# 2  
Old 05-13-2011
Something like this:
Code:
awk 'NR==FNR{a[$1];next}$7 in a{print $7, $NF}' parameters.txt OID.csv

# 3  
Old 05-13-2011
Im getting this error
awk: syntax error near line 1
awk: bailing out near line 1
# 4  
Old 05-13-2011
Quote:
Originally Posted by LavanyaP
Im getting this error
awk: syntax error near line 1
awk: bailing out near line 1
Use nawk or /usr/xpg4/bin/awk on Solaris.
# 5  
Old 05-13-2011
Thanks for that command. But now i have a seperate file
file1:
5629
22002

file2:
.1.3.6.1.4.1.637.61.1.23.3.1.6
.1.3.6.1.4.1.637.61.1.23.3.1.3
.
Now i need to join 2 files and the it should look like this
5629 .1.3.6.1.4.1.637.61.1.23.3.1.6
22002 .1.3.6.1.4.1.637.61.1.23.3.1.3
# 6  
Old 05-13-2011
Code:
paste -d " " file1 file2

This User Gave Thanks to ctsgnb For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing XML using shell script

Well, issue is i have to parse this script to get the VERSION: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleAllowMixedLocalizations</key> ... (9 Replies)
Discussion started by: zorosinister
9 Replies

2. Shell Programming and Scripting

XML parsing using shell script

I have a xml file like this <bul:collectionStrategy name="strategy1"> <bul:collectionTemplateGroup name="15min group"/> <bul:collectionTemplateGroup name="hourly group"/> </bul:collectionStrategy> <bul:CollectionTemplateGroup name="hourly group" > ... (2 Replies)
Discussion started by: LavanyaP
2 Replies

3. Shell Programming and Scripting

XML parsing in a shell script.

Below is a XML I have... <?xml version="1.0" encoding="UTF-8" ?> <component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:XXXXX-www-Install-Manifest manifest.xsd" xmlns="urn:qqqqq-Install-Manifest" name="OM" ... (1 Reply)
Discussion started by: dashok.83
1 Replies

4. Shell Programming and Scripting

Parsing XML using Shell Script

Hello, I'm a starting shell scripter and no Perl knowledge. I've trying to do this for a while: I want to parse an XML file and get certain data out of it and write that data into a CSV file, all this using Shell Scripting (in Bash). Or Perl without any XML Parser/Interpreter (if possible). ... (1 Reply)
Discussion started by: Kage Musha
1 Replies

5. Shell Programming and Scripting

Shell script to parsing log

Hi I Have log like this : 0 234: { 3 2: 04 EE 7 14: '20081114081' 23 1: 00 79 10: '38809' 91 15: '528111510010159' 143 29: 'Streaming/downloading service' 174 3: 'MTV' 179 43: 'rtsp://172.28/MTV2GO-Loop.sdp' 224 1: 05 ... (10 Replies)
Discussion started by: justbow
10 Replies

6. Shell Programming and Scripting

parsing a string in a shell script

I need to parse a string in a shell script. I understand there is some in built function to use that. can someone explain the syntax ? Say, it is like this #!/bin/ksh read input # input is entered as 'welcome' #Now I want to extract say only first 4 characters or last four #characters. ... (19 Replies)
Discussion started by: asutoshch
19 Replies

7. UNIX for Dummies Questions & Answers

shell script parsing with sed

#I'm quite new to scripting and my boss has asked me to solve a simple problem and sadly, I can't figure out how to do it. Any help is appreciated. :confused: #The following is a small shell script and the output that it produces for google.com. #!/bin/sh whois $1 | grep "Name Server"... (5 Replies)
Discussion started by: jjamd64
5 Replies

8. Shell Programming and Scripting

Parsing a line in Shell Script

I have record line somthing like below with first line showing char spacing not real record line 1 | 2 | 3rd Field--------------|-4th field--| This is charcatersapcing of line DF20000000000000000130.7890000000750 I shoudl get two line from above line 1st line should 1 | 2 | 3rd... (3 Replies)
Discussion started by: unishiva
3 Replies

9. Shell Programming and Scripting

Parsing a file in Shell Script

Hi, I have a requirement. I have an application which can take a file as inputs. Now the file can contain any number of lines. The tool has to pick up the first uncommented line and begin processing it. For example the file could be like this: #MANI123|MANI1234 #MANI234|MANI247... (4 Replies)
Discussion started by: sendhilmani123
4 Replies

10. Shell Programming and Scripting

shell script argument parsing

how to parse the command line argument to look for '@' sign and the following with '.'. In my shell script one of the argument passed is email address. I want to parse this email address to look for correct format. rmjoe123@hotmail.com has '@' sign and followed by a '.' to be more... (1 Reply)
Discussion started by: rmjoe
1 Replies
Login or Register to Ask a Question