The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cat operation trichyselva UNIX for Dummies Questions & Answers 0 03-24-2008 06:55 AM
Help with arithmetic operation emjayshaikh Shell Programming and Scripting 3 09-24-2007 12:44 AM
RPC failure on yp operation Remi SUN Solaris 1 05-22-2007 11:15 AM
split operation scotty_123 Shell Programming and Scripting 1 04-05-2007 09:34 AM
string operation fongthai Shell Programming and Scripting 6 11-24-2006 06:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-26-2008
ravis83
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Iterative operation

grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' then how do i iterate the file names??

Last edited by ravis83; 08-27-2008 at 09:20 PM..
  #2 (permalink)  
Old 08-26-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You don't really need iteration, just add more file names to the grep command line.
  #3 (permalink)  
Old 08-26-2008
ravis83
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
ohh well that works for me

Last edited by ravis83; 08-27-2008 at 09:20 PM..
  #4 (permalink)  
Old 08-27-2008
ravis83
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
i got the mistake i was making...i forgot to leave the space in one of the arguments

Last edited by ravis83; 08-27-2008 at 09:46 PM..
  #5 (permalink)  
Old 08-26-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Exactly. The grep output changes so that each match is prefixed with the file name. There are options to turn that off if you don't need it.
  #6 (permalink)  
Old 08-26-2008
ravis83
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
if i then use the code to look up DNS then should i do it with nslookup host or dig?...i know dig is more useful which i read ....but if you could state the use of IFS then it will be great.

Last edited by ravis83; 08-27-2008 at 09:42 PM..
  #7 (permalink)  
Old 08-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Recent versions of host can perform a reverse DNS lookup directly on the IP address. If you have an older version, or wish to use dig or some other tool, you have to convert the IP address into the format used internally for reverse DNS lookups. Here is an example.

Code:
OLDIFS=$IFS
IFS=.
set -- $ip
IFS=$OLDIFS
echo IP=$ip, hostname=`dig +short ptr $4.$3.$2.$1.in-addr.arpa.`
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 09:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0