LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 11-30-2018, 05:19 PM   #1
james000
Member
 
Registered: Sep 2018
Posts: 143

Rep: Reputation: 2
How to segregate a section from big file?


Hello,

I need to know all IP range (ip_prefix), associated with us-west-2 region only from this link - https://ip-ranges.amazonaws.com/ip-ranges.json (it can be opened in wordpad for better visibility)
Please suggest, how would I do it. If vi, awk or sed is needed, I have downloaded it on my linux server.

Thanks
 
Old 11-30-2018, 06:03 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
It might be possible with standard text processing tools like awk, but ideally, you need a tool that understands JSON. Such as jq.
Code:
curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq '.prefixes[] | select(.region == "us-west-2")' | more
This gets the prefixes array from the data, then selects the array elements with the desired region.

jq is available from Ubuntu repos. Not sure about other distros.

Reference: jq manual

Last edited by berndbausch; 11-30-2018 at 06:06 PM.
 
2 members found this post helpful.
Old 11-30-2018, 09:03 PM   #3
james000
Member
 
Registered: Sep 2018
Posts: 143

Original Poster
Rep: Reputation: 2
Thanks much. It solved my problem.
 
  


Reply

Tags
solved



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
[SOLVED] best way to segregate browsing activities planarian Linux - Security 6 06-03-2013 12:00 AM
apt/dpkg: How do I segregate user application packages from system packages? boxyzzy Ubuntu 2 12-03-2010 11:04 AM
Big O, Big Omega, and Big Theta oulevon Programming 7 05-26-2010 07:18 AM
Is a there general method to segregate debugging symbols in Slackware packages? Shingoshi Slackware 7 03-27-2009 08:15 PM
LXer: Why Big Compute and Big Storage will meet Big Pipe at the Last Mile LXer Syndicated Linux News 0 12-23-2007 01:20 PM

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

All times are GMT -5. The time now is 10:56 PM.

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