LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-29-2003, 10:10 PM   #1
Rezon
LQ Newbie
 
Registered: Oct 2003
Posts: 8

Rep: Reputation: 0
Bash Scripting Question


I'm trying to organize IP Addresses in a log by class... I currently have uniquely parsed out the IP Addresses from the log so I have a list of IPs. My problem here lies that I would like to take all IPs starting with 1-128 and store then into a seperate file. I have tried egrep (must be doing something wrong here). Any ideas?

egrep -o `[[1-128]]\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}` IPTEMP | sort -r >> CLASSA

If Awk would be better let me know... but I'm a little new with AWK too.

Thanks in advance,
Rez
 
Old 10-30-2003, 10:00 AM   #2
inTrouble?
LQ Newbie
 
Registered: Oct 2003
Posts: 5

Rep: Reputation: 0
Using awk it's simple

awk -F. '{if ($1<=128) print $0}' IPTEMP | sort -r >> CLASSA

-F set field separator to '.'
$1 is the first field
$0 is the whole line (ip nr)

Good luck
 
Old 10-30-2003, 10:16 AM   #3
Rezon
LQ Newbie
 
Registered: Oct 2003
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks a ton. I knew there had to be an easier way.
 
  


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
Bash scripting question ajaye1971 Linux - Newbie 1 11-16-2005 07:29 PM
Bash scripting question. pete1234 Programming 23 09-22-2005 06:52 PM
bash scripting question mehesque Programming 2 03-07-2004 01:37 PM
Bash scripting question. welby Linux - Software 1 01-14-2004 10:05 AM
Bash Scripting Question RefriedBean Programming 6 09-11-2002 09:06 AM


All times are GMT -5. The time now is 07:52 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration