Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6946417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:33:45+00:00 2026-05-27T13:33:45+00:00

To write a shell script program to grep IP (from the list given) and

  • 0

To write a shell script program to grep IP (from the list given) and search the network for the IP whom it belongs to. Then if the IP belongs to vodafone, telstra, airtel, write them in a file separately for each operator.

So i wrote the script should be like :

for ip_address in `cat ip_address_list`;  
do  
whois $ip_address | grep 'descr' >> final_result 
done  

the output looks like :

$] whois 62.87.90.54 | grep descr
descr: GLOBAL MOBILE OPERATOR
descr: AIRTEL-NETWORK
descr: VODAFONE-NETWORK

Can we modify it more ? Can we include IF statement to separate vodafone etc to include them in a file ?

Or pls mention a good script than mine ?

Pls advise !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:33:46+00:00Added an answer on May 27, 2026 at 1:33 pm
    for ip_address in $(cat ip_address_list); do  
        whois $ip_address | grep 'descr' \
        | while read line ; do
          case "${line}" in 
             *GLOBAL\ MOBILE\ OPERATOR* )
                printf "${line}\n" >> gmo
              ;;
             *AIRTEL-NETWORK* )
                printf "${line}\n" >> air
              ;;
             *VODAFONE-NETWORK* )
                printf "${line}\n" >> voda
              ;;
             * )
                printf "${line}\n" >> all_others 
              ;;
            esac
          done
    done  
    

    Note that in the case statement, you need to escape any spaces in match targets, i.e. *GLOBAL\ MOBILE\ OPERATOR*.

    Also, I don’t have a way to test this right now, so hopefully there are not too many syntax errors :-). If you do find problems, let’s try and setup a chat.

    And, if you are sure whois produces only one line of output per request, you probably dont’t need the while loop. whois $ip | read line ; case "${line}" .... might work.

    Actually managing the constantly increasing files, air, voda, gmo may require some thought on your part.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a shell script where I read a variable from environment.
I need to write a shell script to be scheduled to run daily to
How do I write a shell script (bash on HPUX) that receives a string
I need to write a Shell Script to process a huge folder of nearly
I'm trying to write a shell script that, when run, will set some environment
I want to write a Shell (AWK, Sed also fine) program to take as
I want to write a shell script that loops through all directories under a
This is one of my homework exercise. Write a shell program, which will take
I am trying to write a wrapper script for a command line program (svnadmin
I am trying to run a shell from my python program. I have used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.