The UNIX and Linux Forums  

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
awk script to calculate total appsguy616 Shell Programming and Scripting 2 11-25-2008 11:21 AM
Awk help needed to calculate total senthilkumar_ak Shell Programming and Scripting 7 08-22-2008 01:47 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 05-28-2009
durden_tyler's Avatar
durden_tyler durden_tyler is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 552
Quote:
Originally Posted by rakesh_pagadala View Post
... xyz.unix.com can come any where in the line it need not be at $3 every time

Code:
$
$ cat input.txt
3.209.12.09 xyz xyz.unix.com
3.209.12.09 xyz.unix.com xyz
xyz.unix.com xyz 3.209.12.09
$
$ perl -ne 's/^.*xyz\.([^ ]*).*/$1/; print' input.txt
unix.com
unix.com
unix.com
$

tyler_durden
  #2 (permalink)  
Old 05-28-2009
rakesh_pagadala rakesh_pagadala is offline
Registered User
  
 

Join Date: May 2009
Location: hyderabad
Posts: 20
It worked now Thanks a look . Can you tell me how to post a new form .. I read the manuals but was bit ambiquity in there
  #3 (permalink)  
Old 05-28-2009
rakesh_pagadala rakesh_pagadala is offline
Registered User
  
 

Join Date: May 2009
Location: hyderabad
Posts: 20
Quote:
Originally Posted by durden_tyler View Post
Something like this:


Code:
$
$ cat input.txt
3.209.12.09 xyz xyz.unix.com
$
$ awk '{sub("xyz.","",$3); print $3}' input.txt
unix.com
$

tyler_durden
$ cat input.txt
3.209.12.09 xyz xyz.unix.com

xyz.unix.com can come any where in the command line ... it be like

3.209.12.09 xyz.unix.com xyz so in this case i guess we cant we use $3 in that case how to go about it ..
  #4 (permalink)  
Old 05-28-2009
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514

Code:
sed  -n 's/.*\(xyz\.[aA-zZ][aA-zZ]*\.com\).*/\1/p ' filename


-Devaraj Takhellambam
  #5 (permalink)  
Old 05-28-2009
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514
Did you try the sed command I posted?


Code:
sed  -n 's/.*\(xyz\.[aA-zZ][aA-zZ]*\.com\).*/\1/p ' filename

-Devaraj Takhellambam
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 01:16 AM.


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