LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 10-23-2003, 09:02 AM   #1
inTrouble?
LQ Newbie
 
Registered: Oct 2003
Posts: 5

Rep: Reputation: 0
Shell script for insert ip address into an ordered list of IPs


Could anyone give me some advices?

I need a shell script that takes an IP and inserts it into a file that contains an ordered (for human eyes) lists of IPs - 1 IP / line, followed by a mask and some comments.

List is ordered "for human eyes" I mean for example
122.0.7.x comes before 122.0.11.x


Does anyone have something like this?
Or could you tell me which is the best way to compare an IP to a list of IPs - I want to insert the new IP in the right place, I mean, if the new ip is 18.33.55.12

and the list is

...
18.33.54.9

- i want to insert it here

18.33.102.5
...

Thanks for any tips
 
Old 10-26-2003, 09:14 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Just echo the line into the file, then use sort (sort "file" -o "file").
 
Old 10-27-2003, 02:21 AM   #3
inTrouble?
LQ Newbie
 
Registered: Oct 2003
Posts: 5

Original Poster
Rep: Reputation: 0
Oh - seems like I wasn't so clear - sorry unSpawn.
I've tried sort but it's not exactly what I need - I mean, it sorts IPs like this:

142.xxx.xxx.xxx
15.xxx.xxx.xxx

while I would need the order "as for human eyes" i.e.

15.xxx.xxx.xxx
142.xxx.xxx.xxx

Thanks and sorry for my poorly written explanation
 
  


Reply



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
snort 2.4.1 (inline IPS) +shorewall 2.4.x where best to insert the QUEUE in iptables Emmanuel_uk Linux - Security 5 10-18-2005 06:48 AM
Perl question: how to insert an e-mail address in a script Pastorino Programming 3 08-08-2005 08:28 AM
Shell script ip address format check. rooch84 Linux - Software 6 08-18-2004 09:14 AM
Insert an ordered list into your message SidA Red Hat 0 06-19-2004 07:49 PM
IPs list eduac Linux - Networking 6 08-14-2003 01:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:26 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
Open Source Consulting | Domain Registration