The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else hariza Shell Programming and Scripting 4 09-18-2008 03:56 AM
grep and fetching lines after grep arghya_owen Shell Programming and Scripting 2 07-16-2008 08:25 AM
Grep neeto UNIX for Dummies Questions & Answers 2 04-21-2008 05:15 PM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-05-2007 03:59 AM
Make grep -c display like grep -n? Jerrad Shell Programming and Scripting 2 08-25-2006 01:20 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 10-27-2008
khestoi khestoi is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 66
how to grep this

in this line
6347 9.0.4 22772 63743 Running C=US,O=SBC,OU=DGBusSvcs,CN=HostLookup

how can i get only this value
63743?
  #2 (permalink)  
Old 10-27-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink Two solutions


Code:
> echo 6347 9.0.4 22772 63743 Running C=US,O=SBC,OU=DGBusSvcs,CN=HostLookup | cut -d" " -f4
63743
> echo 6347 9.0.4 22772 63743 Running C=US,O=SBC,OU=DGBusSvcs,CN=HostLookup | awk '{print $4}'
63743

  #3 (permalink)  
Old 10-27-2008
khestoi khestoi is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 66
thanks so how do i save it to a variable?
sorry for such a noob question
  #4 (permalink)  
Old 10-27-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink saving to a variable..


Code:
> myval=$(echo 6347 9.0.4 22772 63743 Running C=US,O=SBC,OU=DGBusSvcs,CN=HostLookup | cut -d" " -f4)
> echo $myval
63743

  #5 (permalink)  
Old 10-27-2008
khestoi khestoi is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 66
I just got the solution myself by using this ctl_rsrc -l Active | grep 6.1.5 | grep HostLookup | awk '{print $4}' >$VALUE well thanks anyway
another question is if there are many lines then there will be many results for the 4th column
so i need to have some kind of an array for that since i need to access those values to stop all services within those ports
any ideas?
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 11:54 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