nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

find subdomains in url

This is a discussion on find subdomains in url within the Shell scripting forums, part of the Development/Scripting category; I want to find out subdomains in the url usinf shell script. e.g narendra.eukhost.com abc.domainname.co.uk I want to find extract ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-22-2007, 09:19 AM
Junior Member
User
 
Join Date: Nov 2007
My distro: RedHat
Posts: 3
Rep Power: 0
nvbhole is on a distinguished road
Default find subdomains in url

I want to find out subdomains in the url usinf shell script.
e.g
narendra.eukhost.com
abc.domainname.co.uk

I want to find extract narendra & abc from the above urls.
Please any one can suggest idea or script ?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-22-2007, 11:02 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 557
Rep Power: 6
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

You can use sed as follows
Code:
echo "narendra.eukhost.com" | cut -d'.' -f1
You can store all subdomains in a file or variable and run for loop:
Code:
#!/bin/sh
DOMAINS="narendra.eukhost.com txt.xyz.com abc.yyyy.co.in"
for d in $DOMAINS
do
  echo $d | cut -d'.' -f1
done
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #3 (permalink)  
Old 12-22-2007, 12:12 PM
Junior Member
User
 
Join Date: Nov 2007
My distro: RedHat
Posts: 3
Rep Power: 0
nvbhole is on a distinguished road
Default

Thanks Rocky Jr. for the solution.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Lighttpd socket with multiple subdomains or single IP muks Web servers 2 03-17-2007 04:48 AM
find out what chip nic Linux software 1 01-30-2006 04:06 PM


All times are GMT +5.5. The time now is 04:42 PM.


Powered by vBulletin® Version 3.7.2 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36