10-13-2008
Yes your assumption is correct and this is a real world problem
What iam trying to do is commenting the duplicate Ip's found in the text file ignoring the first occurance as to be valid IP for a valid mac and from the second occurance onwards commenting the duplicate IPs at the starting of the line.
file 1.txt with following entries as shown:
0152364|134444|10.20.30.40|015236433
0233654|122555|10.20.30.50|023365433
**
**
**
file 2.txt with following entries as shown:
0152364|134444|10.20.30.40|015236433
0233654|122555|10.20.30.50|023365433
0789456|332211|10.20.30.40|078945633
1234567|225522|10.20.30.50|123456733
0321654|999999|10.20.30.40|032165433
0456123|777899|10.20.30.40|045612333
***
***
***
i need to have the following output in 2.txt as shown:
0152364|134444|10.20.30.40|015236433
0233654|122555|10.20.30.50|023365433
#0789456|332211|10.20.30.40|078945633
#1234567|225522|10.20.30.50|123456733
#0321654|999999|10.20.30.40|032165433
#0456123|777899|10.20.30.40|045612333
***
***
***
The correct script i wrote is
for i in `cat 1.txt |cut -d"|" -f3`
do
cat 2.txt |sed "s/^\(.*\|$i\|.*)/#\1/g" > tmp.txt
mv tmp.txt 2.txt
done
But the above script will comment all the occurance.
Your help is appreciated.
Thanks
-imas
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am new to this forum and i would like to get help in this issue.
I have a file 1.txt as shown:
apple
banana
orange
apple
grapes
banana
orange
grapes
orange
....
Now i would like to search for pattern say apple or orange and then put a # at the beginning of the pattern... (2 Replies)
Discussion started by: imas
2 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I think you ppl did not get my question correctly, let me explain
I have 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:
... (1 Reply)
Discussion started by: imas
1 Replies
3. Shell Programming and Scripting
trying to use sed in finding a matching pattern in a file then deleting
the next line only .. pattern --> <ad-content>
I tried this but it results are not what I wish
sed '/<ad-content>/{N;d;}' akv.xml > akv5.xml
ex,
<Celebrant2First>Mickey</Celebrant2First>
<ad-content>
Minnie... (2 Replies)
Discussion started by: aveitas
2 Replies
4. UNIX for Dummies Questions & Answers
I have a file that will sometimes contain a pattern. The pattern is this:
W/D FRM CHK 00
I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (1 Reply)
Discussion started by: nickg
1 Replies
5. Shell Programming and Scripting
I have a file that will sometimes contain a pattern. The pattern is this:
FRM CHK 0000
I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (4 Replies)
Discussion started by: nickg
4 Replies
6. Shell Programming and Scripting
i have a file sample.txt containing
i want to delete lines starting with 123 neglecting spaces and tabs.
but not lines containing 123. i.e.
i want files sample.txt as
help me
thanxx (4 Replies)
Discussion started by: yashwantkumar
4 Replies
7. Shell Programming and Scripting
Hi, just tried some script, awk, sed for the last 2 hours and now need help.
Let's say I have a huge file of 800,000 lines like this :
It's a tedious job to look through it, I'd like to remove those useless lines in it as there's a few thousands :
Or to be even more precise :
if line1 =... (6 Replies)
Discussion started by: Zurd
6 Replies
8. Shell Programming and Scripting
'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. UNIX for Dummies Questions & Answers
Hi all!
Thanks for taking the time to view this!
I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern.
Example:
Drink a soda
Eat a banana
Eat multiple bananas
Drink an apple juice
Eat an apple
Eat multiple apples
I... (8 Replies)
Discussion started by: demmel
8 Replies
10. UNIX for Beginners Questions & Answers
I have a file with a list of references towards the end and want to apply a grep for some string.
text ....
@unnumbered References
@sp 1
@paragraphindent 0
2017. @strong{Chalenski, D.A.}; Wang, K.; Tatanova, Maria; Lopez,
Jorge L.; Hatchell, P.; Dutta, P.; @strong{Small airgun... (1 Reply)
Discussion started by: kristinu
1 Replies
LEARN ABOUT DEBIAN
mac-vendor
MAC-VENDOR(5) File Formats Manual MAC-VENDOR(5)
NAME
mac-vendor - Ethernet vendor file for arp-scan
SYNOPSIS
mac-vendor.txt
DESCRIPTION
The mac-vendor.txt contains Ethernet MAC to vendor string mappings for arp-scan. It is used in addition to the IEEE OUI and IAB listings
in ieee-oui.txt and ieee-iab.txt. It is for MAC-vendor mappings that are not covered by the IEEE manufacturer listings.
Each line in the mac-vendor.txt file contains a MAC-vendor mapping in the form:
<MAC-Prefix><TAB><Vendor>
Where <MAC-Prefix> is the prefix of the MAC address in hex, and <Vendor> is the name of the vendor. The prefix can be of any length from
two hex digits (one octet) to twelve hex digits (six octets, the entire Ethernet hardware address). The alphabetic hex characters [A-F]
must be entered in upper case.
For example:
012345 would match 01:23:45:xx:xx:xx, where xx represents any value;
0123456 would match 01:23:45:6x:xx:xx; and
01234567 would match 01:23:45:67:xx:xx.
Blank lines and lines beginning with "#" are ignored.
The order of entries in the file is not important. arp-scan will attempt to match larger prefixes before trying to match smaller ones, and
will stop at the first match.
FILES
/usr/local/share/arp-scan/mac-vendor.txt
EXAMPLE
# From nmap Debian bug report #369681 dated 31 May 2006
525400 QEMU
B0C420 Bochs
# From RFC 2338: 00-00-5E-00-01-{VRID}
00005E0001 VRRP (last octet is VRID)
# Microsoft WLBS (Windows NT Load Balancing Service)
# http://www.microsoft.com/technet/prodtechnol/acs/reskit/acrkappb.mspx
02BF Microsoft WLBS (last four octets are IP address)
AUTHOR
Roy Hills <Roy.Hills@nta-monitor.com>
SEE ALSO
arp-scan(1)
get-oui(1)
get-iab(1)
arp-fingerprint(1)
http://www.nta-monitor.com/wiki/ The arp-scan wiki page.
March 30, 2007 MAC-VENDOR(5)