[nycbug-talk] Scripting Question

Kevin Reiter KReiter at insidefsi.net
Fri Mar 9 16:10:04 EST 2007

Sorry for the top post, but Outlook sucks (I have no choice here at work...)

Thanks to everyone that provided auggestions on this.  I'm almost done with this monster, and sofar, everything is working perfectly.  Here's a snippet that did the trick (and what I'm doing):

# Get a full list of ports in 1 file.  Since there's a full subnet
# worth of files, put it in a temp location:
mkdir temp
cp $nmaplog/*.nmap temp/
cd temp/
cat ./*.nmap >> nessus_temp
cat nessus_temp | grep open | cut -f -d\/ > ports.tmp

# Then convert it into 1 line:
cat ports.tmp |sort -n|uniq|xargs|sed 's/ /,/g' > ports.list

mv ports.list ..
cd ..

# Delete the temp directory:
rm -rf ./temp

# Work some magik:
ports=`cat ports.list`
temp="port_range = $ports"

# Rewrite the nessusrc with the ports we want to scan:
sed -e "s/port_range =/$temp/" $nessusfile > nessus.tmp
mv nessus.tmp $nessusfile

-----Original Message-----
From: Roland Dowdeswell [mailto:elric at imrryr.org]
Sent: Friday, March 09, 2007 2:28 PM
To: James
Cc: Kevin Reiter; NYCBUG Talk
Subject: Re: [nycbug-talk] Scripting Question 

On 1173465392 seconds since the Beginning of the UNIX epoch
James wrote:
>Kevin Reiter wrote:
>> Follow-up question:  Is there a quick and dirty way to check for duplicate e
>ntries, and eliminate them if they exist?
>> For example:
>> 1
>> 1
>> 2
>> 3
>> 3
>> 3
>> 4
>> 5
>> I need: 1,2,3,4,5
>> Is there a quick check/solution for this?
>uniq should work, no?

sort -u.

or if you want line counts, something like:

sort | uniq -c | sort -nr

This message may contain confidential or proprietary information and is intended solely for the individual(s) to whom it is addressed.  If you are not a named addressee you should not disseminate, distribute or copy this e-mail or act upon the information contained herein.  Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.

More information about the talk mailing list