Output to single line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output to single line
# 8  
Old 03-16-2012
OK, but what is the criterion, is it that there is a dot(.) in the name?

Code:
sed '/\./{N;s/\n/, /;}'

Code:
awk '/\./{getline $2}1' OFS=', '

# 9  
Old 03-16-2012
If you could give us an example of

1). what output you get with the following command :

Code:
echo "dis ql(*) CLUSTER"|runmqsc -e CT.QM.CNEDCT1

2). and what output you expect, some people may be able help to make your whole command line more simple.
# 10  
Old 03-16-2012
1) command remove below line from output which i was getting earlier. I have posted the same in this thread only.

I tried below command
Code:
echo "dis ql(*) CLUSTER"|runmqsc -e CT.QM.CNEDCT1| egrep 'QUEUE|CLUSTER'|egrep -v 'SYSTEM|XMITQ'| sed -e 's/QUEUE(/ /g' -e \
's/TYPE(QLOCAL)/ /g' -e 's/CLUSTER(/ /g' -e 's/)/ /g'|sed '/\./{N;s/\n/, /;}'

Getting Output
Quote:
ABC
CT.CL.AIBGTCT2 , CT.CL.AIBGTCT2.GTC.AIB_TO_GTC_MB_MNSD_REQ.01
CT.CL.B2BGTCT1 , CT.CL.B2BGTCT1.GTC.B2B_TO_GTCJO_MNSD_MB_RES.01
I am expecting output as

Quote:

CT.CL.AIBGTCT2.GTC.AIB_TO_GTC_MB_MNSD_REQ.01, CT.CL.AIBGTCT2
CT.CL.B2BGTCT1.GTC.B2B_TO_GTCJO_MNSD_MB_RES.01, CT.CL.B2BGTCT1
(First line i have given "," because there is no value for CLUSTER property of ABC)

Last edited by vbe; 03-16-2012 at 05:36 PM.. Reason: replace quote by code
# 11  
Old 03-16-2012
Could you please paste just the result of the command below :

Code:
echo "dis ql(*) CLUSTER"|runmqsc -e CT.QM.CNEDCT1

?
# 12  
Old 03-16-2012
Output is
Code:
AMQ8409: Display Queue details.
   CLUSTER( )                              QUEUE(ABC)
AMQ8409: Display Queue details.
   CLUSTER(CT.CL.AIBGTCT2)
   QUEUE(CT.CL.AIBGTCT2.GTC.AIB_TO_GTC_MB_MNSD_REQ.01)
AMQ8409: Display Queue details.
   CLUSTER(CT.CL.B2BGTCT1)
   QUEUE(CT.CL.B2BGTCT1.GTC.B2B_TO_GTCJO_MNSD_MB_RES.01)

# 13  
Old 03-16-2012
A quick lazy shot according to the outpout you've given :

Code:
echo "dis ql(*) CLUSTER"|runmqsc -e CT.QM.CNEDCT1 | awk '/QUEUE/&&length($NF)>6{print $NF;next}' RS=')' FS='(' | sed 's/\(.*\)\.GTC\..*/&, \1/'

You can also give a try to :
Code:
echo "dis ql(*) CLUSTER"|runmqsc -e CT.QM.CNEDCT1 | nawk '/CLUSTER/{c=$NF}/QUEUE/{print $NF","c}{next}' RS=')' FS='('


Code:
$ cat f1
AMQ8409: Display Queue details.
CLUSTER( ) QUEUE(ABC)
AMQ8409: Display Queue details.
CLUSTER(CT.CL.AIBGTCT2)
QUEUE(CT.CL.AIBGTCT2.GTC.AIB_TO_GTC_MB_MNSD_REQ.01)
AMQ8409: Display Queue details.
CLUSTER(CT.CL.B2BGTCT1)
QUEUE(CT.CL.B2BGTCT1.GTC.B2B_TO_GTCJO_MNSD_MB_RES.01)
Reply With Quote
$ cat f1 | nawk '/CLUSTER/{c=$NF}/QUEUE/{print $NF", "c}{next}' RS=')' FS='('
ABC,  
CT.CL.AIBGTCT2.GTC.AIB_TO_GTC_MB_MNSD_REQ.01, CT.CL.AIBGTCT2
CT.CL.B2BGTCT1.GTC.B2B_TO_GTCJO_MNSD_MB_RES.01, CT.CL.B2BGTCT1


Last edited by ctsgnb; 03-16-2012 at 07:59 PM..
# 14  
Old 03-16-2012
HI,

I have given only some part of output. But you command is not giving all the queues and clusters. Only few it is giving. Actually i want out put like
QUEUE CLUSTER
---------------------------------------------------------
Code:
ABC, (Blank space as CLUSTER property as blank but "," must come after queue)
CT.CL.AIBGTCT2.GTC.AIB_TO_GTC_MB_MNSD_REQ.01, CT.CL.AIBGTCT2
CT.CL.B2BGTCT1.GTC.B2B_TO_GTCJO_MNSD_MB_RES.01,CT.CL.B2BGTCT1
CT.PR.CNEDCT1.SIMPLE_TO_GTC_MODB_REQ.01, (Blank space as CLUSTER property as blank but "," must come after queue)

there are many othere queues which i can't paste here.

---------- Post updated at 06:07 PM ---------- Previous update was at 05:57 PM ----------

Thanks it seems it is working

Last edited by Scott; 03-19-2012 at 05:21 PM.. Reason: CODE TAGS
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Output to file print as single line, not separate line

example of problem: when I echo "$e" >> /home/cogiz/file.txt result prints to file as:AA BB CC I need it to save to file as this:AA BB CC I know it's probably something really simple but any help would be greatly appreciated. Thank You. Cogiz (7 Replies)
Discussion started by: cogiz
7 Replies

2. Shell Programming and Scripting

convert single line output to multiple line

Hi all, I have a single line output like below echo $ips 10.26.208.28 10.26.208.26 10.26.208.27 want to convert above single line output as below format. Pls advice how to do ? 10.26.208.28 10.26.208.26 10.26.208.27 Regards Kannan (6 Replies)
Discussion started by: kamauv234
6 Replies

3. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

4. Shell Programming and Scripting

Merge multi-line output into a single line

Hello I did do a search and the past threads doesn't really solve my issue. (using various awk commands) I need to combine the output from java -version into 1 line, but I am having difficulties. When you exec java -version, you get: java version "1.5.0_06" Java(TM) 2 Runtime... (5 Replies)
Discussion started by: flagman5
5 Replies

5. Shell Programming and Scripting

Output to be in single line

Hi All, Small script but :wall:, please help in this regard. for i in 1 2 3 do echo $i done result : 1 2 3 I want the above to be printed as below expected result: 1 2 3 Thanks in advance :) (3 Replies)
Discussion started by: girish_satyam
3 Replies

6. Shell Programming and Scripting

Output coming in different line instead of single line

Hi Guys, I have an oracle database, I am trying to query the database and route it to file. But the records instead of coming in a single line, are coming in three lines. Can you please help me.. in this.. sqlplus -s $SRMUserid/$SRMPassword@$SRMServer<< EOF >log.out; select * from... (5 Replies)
Discussion started by: mac4rfree
5 Replies

7. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

8. AIX

ls command output in single line

Hi, Can anyone suggest me how can I display the output of ls command in single line with some delimiter say pipe (|)? I know it can be done by writing a script by using the loops but I wanted to know are there any other single line commands? Thanks for your help Sheshadri (7 Replies)
Discussion started by: arsheshadri
7 Replies

9. Shell Programming and Scripting

Multi-line output to single line

Hello, How can I take the following output: outputa outputb outputc and turn it into single line ouput, with a single space between each field like below: outputa outputb outputc (7 Replies)
Discussion started by: LinuxRacr
7 Replies

10. Shell Programming and Scripting

Need output in different lines not in one single line

I am getting the coutput like this as show below in one single line, where as the command is executed is several lines and the output should also be requied in several lines, not in one single line. Anyone any idea? p4 opened -a | grep *locked* | awk '{ printf $8 }' >/tmp/aa $ cat... (1 Reply)
Discussion started by: csaha
1 Replies
Login or Register to Ask a Question