LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-05-2006, 03:38 AM   #16
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61

grep searches lines that matches a certain pattern or regular expression and returns the lines matched.
grep -E (or egrep) uses Extended Regular Expressions for the matching.
In short, the reg. expression
'W\.X\.Y\.Z\.$'
matches all lines ending on ('$' at the end) "W.X.Y.Z." (ie host outputs '<host or domain> mail is handled by <DNS priority> <server>'
The backslash before the '.' is an escape character that avoids having '.' interpreted as 'any random character'.

sed, short for stream editor, manipulates a stream line-by-line.
The sed command I used above does the following:
-e tells sed that the next argument is a editing command.
's/abc/def/' : is a command to substitute (hence the "s" in front) the pattern "abc" by "def" in each line and outputs the result. If "abc" isn't found in the input line, the line is outputted without change.
The patterns can be strings, regular expressions or a combination of both.

Whereas grep is for line-based searching, cut is more for byte/column searching.
For instance,
cut -d' ' -f7 says:
Split up the lines, based on the ' ' (space) as delimiter (-d option) and output only the 7th field (-f7).
You can also ask for ranges of fields (ie -f1-6 (=from first to sixth field) or -f2- (=from 2nd field to the end of the line)).

Personnally, I would recommend reading up on regular expressions. They can be a little difficult and cryptic at first, but they are commonly used.

Check out also the information on tldp.org (the linux documentation project), the tutorials/how-to's on this site and maybe also linux.about.com.
 
Old 07-05-2006, 06:35 AM   #17
Braynid
Member
 
Registered: May 2006
Location: Romania
Distribution: CentOS
Posts: 140

Original Poster
Rep: Reputation: 15
Okie so this is sord of the final version, i've dropped the idea to verify the NS, i'll just do it myself with 'dig -t NS $1 +short' if it's the right one i'll know.

Code:
function dns ()
{
####################################
echo "                             "
echo DNS resolve:
echo "                             "
dig +nocmd +nostats +nocomments +noquestion $1
echo "                             "
echo Inregistrari MX:
echo "                             "
host -t mx $1
echo "                             "
echo "Sunt folosite urmatoarele NS-uri:"
echo "                             "
dig -t NS $1 +short
echo "                             "
####################################
}
Guys thanks for all the kind support. Be good!

@timmeke the information you give there makes me think of adding some improvements to my script, thanks a million times!

Last edited by Braynid; 07-05-2006 at 06:38 AM.
 
Old 07-05-2006, 06:45 AM   #18
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
You're very welcome, Braynid.
 
  


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
DNS query sanw2k Linux - Networking 1 03-12-2005 12:31 AM
Clients won't query DNS server BruceC Linux - Newbie 3 10-06-2004 09:43 AM
DNS query chynna_v Linux - Newbie 1 09-15-2004 05:57 AM
DNS query for all Domains dominant Linux - Networking 2 04-05-2004 12:24 PM
DNS Query Attack?? Manuel-H Linux - General 0 04-06-2003 10:00 PM

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

All times are GMT -5. The time now is 10:35 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration