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
Awking!! Printing decimal output is struck divzz Shell Programming and Scripting 4 05-28-2008 09:02 AM
can i do XML parsing usind sed arunkumar_mca Shell Programming and Scripting 3 05-10-2007 06:13 AM
printing output more than 13 Krrishv Shell Programming and Scripting 2 01-22-2007 05:35 AM
Printing to a Savin - Size of output wrong h1timmboy AIX 2 02-28-2006 09:19 AM
Printing output to the monitor jyotipg Shell Programming and Scripting 2 06-22-2004 06:41 AM

Reply
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-01-2009
unahb1 unahb1 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 2
printing portion of the output usind sed/awk

friends, i am a newbie in scripting. could someone help me in selecting only the last column of below ps command output ?


Code:
mqm 14 16466   0   Sep 15 ?           0:01 /opt/mqm/bin/runmqlsr -r -m QMGR.INBOUNDSSL -t TCP -p 1415 -i 5.1.26.5
     mqm 12 16700   0   Sep 15 ?           0:00 /opt/mqm/bin/runmqlsr -r -m QMGR.EUMEA -t TCP -p 1414 -i 10.1.122.10
     mqm 11 16472   0   Sep 15 ?           0:00 /opt/mqm/bin/runmqlsr -r -m QMGR.INBOUND -t TCP -p 1416 -i 5.1.26.5

I am looking for below output only :-

Code:
/opt/mqm/bin/runmqlsr -r -m QMGR.INBOUNDSSL -t TCP -p 1415 -i 5.1.26.5
/opt/mqm/bin/runmqlsr -r -m QMGR.EUMEA -t TCP -p 1414 -i 10.1.122.10
/opt/mqm/bin/runmqlsr -r -m QMGR.INBOUND -t TCP -p 1416 -i 5.1.26.5
using either grep/awk/sed.any pointers are highly appreciated.

Last edited by vgersh99; 10-01-2009 at 12:33 PM.. Reason: code tags, PLEASE!
  #2 (permalink)  
Old 10-01-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Code:
echo 'mqm 14 16466 0 Sep 15 ? 0:01 /opt/mqm/bin/runmqlsr -r -m QMGR.INBOUNDSSL -t TCP -p 1415 -i 5.1.26.5' | sed 's#[^/]*\(/.*\)#\1#'


---------- Post updated at 11:33 AM ---------- Previous update was at 11:33 AM ----------

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
  #3 (permalink)  
Old 10-01-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,312
Another one:

Code:
<command> | sed 's_[^/*]*__'
  #4 (permalink)  
Old 10-01-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Quote:
Originally Posted by Franklin52 View Post
Another one:

Code:
<command> | sed 's_[^/*]*__'
a typo I reckon - you don't need an 'inner' '*':
Code:
<command> | sed 's_[^/]*__'
  #5 (permalink)  
Old 10-01-2009
unahb1 unahb1 is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 2
thanks a lot vgersh99,Franklin52 for quick and prompt response.hmm I need to really understand the command now..
Reply

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 06:49 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