printing portion of the output usind sed/awk

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting printing portion of the output usind sed/awk
# 1  
Old 10-01-2009
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 ?

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

I am looking for below output only :-

/opt/mqm/bin/runmqlsr -r -m QMGR.INBOUNDSSL -t TCP -p 1415 -i
/opt/mqm/bin/runmqlsr -r -m QMGR.EUMEA -t TCP -p 1414 -i
/opt/mqm/bin/runmqlsr -r -m QMGR.INBOUND -t TCP -p 1416 -i

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  
Old 10-01-2009
echo 'mqm 14 16466 0 Sep 15 ? 0:01 /opt/mqm/bin/runmqlsr -r -m QMGR.INBOUNDSSL -t TCP -p 1415 -i' | 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  
Old 10-01-2009
Another one:

<command> | sed 's_[^/*]*__'

# 4  
Old 10-01-2009
Originally Posted by Franklin52
Another one:

<command> | sed 's_[^/*]*__'

a typo I reckon - you don't need an 'inner' '*':
<command> | sed 's_[^/]*__'

# 5  
Old 10-01-2009
thanks a lot vgersh99,Franklin52 for quick and prompt response.hmm I need to really understand the command now..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk printing leading tab in output

The awk below executes and produces the current output. it skips the header in row 1 and prints $4,$5,$6 and then adds the header row back. The problem is that it keeps the tailing tab and prints it in front of $1. I could add a pipe to remove the tab, but is there a better way to do it with on... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. Shell Programming and Scripting

Printing the output of sed using a loop

So I am writing a bash script that will search a file line by line for unix timestamps, store all of the timestamps into an array, then check how many of those timestamps were created within the last hour, and finally increment a counter every time it finds a timestamp created within the last hour.... (6 Replies)
Discussion started by: jsikarin
6 Replies

3. Shell Programming and Scripting

awk printing output to new line

Hi I have a file profile.txt with the below input: {"atgUserId":"736f14c4-eda2-4531-9d40-9de4d6d1fb0f","firstName":"donna","lastName":"biehler","email":"","receiveEmail":"y es"}, {"atgUserId":"c3716baf-9bf8-42da-8a44-a13fff68d20f","firstName":"Gilberto... (6 Replies)
Discussion started by: ankur328
6 Replies

4. Shell Programming and Scripting

Help! Printing out CSV output from awk Pattern Match

Hi, I need to search for a word using Awk and print out the line the word is in and every line after the search phrase until I hit this #------------. Then I need to send it to a csv file. So basically the input file format is like this:... (1 Reply)
Discussion started by: An0mander
1 Replies

5. Shell Programming and Scripting

sed , awk script for printing matched line before regular expression

hi All , I am having a large file with lots of modules as shown below ############################################### module KKK kksd kskks jsn;lsm jsnlsn; Ring jjsjsj kskmsm jjs endmodule module llll 1kksd11 k232skks j33sn;l55sm (6 Replies)
Discussion started by: kshitij
6 Replies

6. Shell Programming and Scripting

Searching and printing the only pattern using awk,sed or perl

Hi All, i have an output of command vmstat as below : $ vmstat System configuration: lcpu=4 mem=5376MB ent=1.00 kthr memory page faults cpu ----- ----------- ------------------------ ------------ ----------------------- r b avm fre re pi... (10 Replies)
Discussion started by: omkar.jadhav
10 Replies

7. UNIX for Dummies Questions & Answers

Grab Portion of Output Text (sed, grep, awk?)

Alright, here's the deal. I'm running the following ruby script (output follows): >> /Users/name/bin/acweather.rb -z 54321 -o /Users/name/bin -c Clouds AND Sun 57/33 - Mostly sunny and cool I want to just grab the "57/33" portion, but that's it. I don't want any other portion of the line. I... (5 Replies)
Discussion started by: compulsiveguile
5 Replies

8. Shell Programming and Scripting

KSH Output/Strip portion of file in HP-UX

I have a file, we'll call it file.txt. It has thousands of lines of all kinds of output at any given time (ie. foo bar foo bar) I need to copy out just a portion of the file from Point-A to Point-B. I'd like to save off just that portion to a file called test123xyz.txt. How do I do that? ... (7 Replies)
Discussion started by: austin881
7 Replies

9. Shell Programming and Scripting

can i do XML parsing usind sed

Hi all... I want to parse a xml filein unix .. Can i use SED or unix script to parse the xml file .. If so can anyone show a sample script that will parse the xml file .. Thanks in advance, Arun ,,,, (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

10. UNIX for Dummies Questions & Answers

erasing portion of line with sed (only once)

hi, I'm trying to use sed to erase everything, up to the first parenthesis. for example: input: blah blah blah (aldj) test (dafs) test test. output: (aldj) test (dafs) test test. how would i do this? I was fooling around with the parenthesis, and i only got it to apply on all parenthesis.... (1 Reply)
Discussion started by: gammaman
1 Replies
Login or Register to Ask a Question