View Single Post

  #2 (permalink)  
Old 12-22-2007, 12:02 PM
rockdalinux's Avatar
rockdalinux rockdalinux is offline
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough 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