LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-24-2004, 02:55 PM   #1
invisible_ink
LQ Newbie
 
Registered: Nov 2004
Distribution: YellowDog
Posts: 1

Rep: Reputation: 0
Adding only new text/simplifying lists


I'm trying to parse my /var/log/secure file so that I can close down my system with iptables after repeated incorrect logins. I can extract the correct IP address to a file, but the file (depending on the number of login attempts) lists the same address multiple times. Is there any way to either 1) only add a line of text to a file if that line of text isn't already present... or 2) parse a file with a list of IP addresses and come up with a list of each IP only one time? Or to put that another way:

aaa.bbb.ccc.ddd
aaa.bbb.ccc.ddd
aaa.bbb.ccc.ddd
aaa.bbb.ccc.ddd
aaa.bbb.ccc.ddd
aaa.bbb.ccc.ddd
eee.fff.ggg.hhh
eee.fff.ggg.hhh
eee.fff.ggg.hhh
eee.fff.ggg.hhh

[magic happens here]

aaa.bbb.ccc.ddd
eee.fff.ggg.hhh

Thank you kindly.
ink
 
Old 11-24-2004, 03:07 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Just add a -u to the sort (that you're presumably
doing)...


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding text to lines in a file tpreitano Linux - General 2 10-04-2005 10:30 AM
adding text file browser Linux - General 5 09-09-2005 10:10 PM
Simplifying guest-login - usability kiwibird Linux - General 1 07-24-2005 10:12 PM
adding packages after installation and partiton lists? buffed317 Slackware 6 08-10-2004 09:51 PM
Adding headers to text files Madrinator Linux - General 1 04-21-2004 07:46 PM


All times are GMT -5. The time now is 03:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration