Arranging output for 2 commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Arranging output for 2 commands
# 1  
Old 10-03-2016
Arranging output for 2 commands

I am trying to run 2 sets of commands but want their output in a particular format.

The 2 commands are :

Code:
md5sum $WAR_DIR/$war

and
Code:
java -jar $WAR_DIR/$war | grep build.release.version | awk '{print $3}'

The first command gives an output of
Code:
5f5261a33b92a36f80218cf14e8271ad  /opt/msdp/ca/iam_cac/webapps/consumerProfile.war

The second command gives an output of
Code:
1.01.00.00

Now I am running this remotely ::

Code:
ssh user@10.169.99.189 "md5sum $WAR_DIR/$war ; java -jar $WAR_DIR/$war | grep build.release.version | awk '{print $3}'"

The output I am getting is::

Code:
5f5261a33b92a36f80218cf14e8271ad  /opt/msdp/ca/iam_cac/webapps/consumerProfile.war
1.01.00.00

The output I am looking for is all the 3 values in 1 line ::

Code:
5f5261a33b92a36f80218cf14e8271ad  /opt/msdp/ca/iam_cac/webapps/consumerProfile.war 1.01.00.00

Do I need to use some awk or sed functionality here ?
# 2  
Old 10-03-2016
Untested, but the following should come close to what you seem to want:
Code:
ssh user@10.169.99.189 "{ md5sum \"$WAR_DIR/$war\"; java -jar \"$WAR_DIR/$war\"; } | awk 'NR==1{s=$0;next}/build[.]release[.]version/{print s, $3;exit}'"

# 3  
Old 10-04-2016
Using the nearest to the code that I could but converting the grep into an awk clause, could I also suggest (also untested):-
Code:
ssh user@10.169.99.189 "md5sum \"$WAR_DIR/$war\" ; java -jar \"$WAR_DIR/$war\" | awk '/build.release.version/ {print $3}' " | tr "\n" " "

This does assume that you will only get the items you wanted returned. The tr simple converts the new-line into a space, which may or may not be what you want or could have some unwanted side-effects.


I hope that this helps or get corrected if appropriate.
Robin
# 4  
Old 10-04-2016
How about
Code:
ssh host "commands" | tr '
' ' '

Or, move the tr to run in the server, if electricity is cheaper there Smilie
Juha

Meh, I'm an idiot, same as rbatte1's post.

Last edited by Juha Nurmela; 10-04-2016 at 09:52 AM..
# 5  
Old 10-09-2016
You could try:

Code:
$ echo $(ssh user@10.169.99.189 "md5sum $WAR_DIR/$war ; java -jar $WAR_DIR/$war | awk '/build.release.version/ {print $3}' ")

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Arranging the command output into an html table format

Hi, I need to format a command output for the beolow command: runmqckm -cert -list -db $MQ_KDB -pw $PASSWD -expiry $EXP | grep -v "Certificates in database" The output will be: "ABC - cert name" From: Tuesday, May 25, 1999 11:09:40 AM CDT To: Saturday, May 25, 2019 11:39:40 AM CDT ... (3 Replies)
Discussion started by: bdpl
3 Replies

2. Shell Programming and Scripting

Arranging the output of a shell script into tables

Hi guys. I am new to this forum so cheers :) I have a question. I have created a shell script that puts all the output into 1 file. The out put is like this: -----IP------ Data Data Data -----IP------ Data Data Data How can i arrange this to be like this: IP | Data |... (3 Replies)
Discussion started by: Pandera
3 Replies

3. Shell Programming and Scripting

Compare output from two commands

Hello folks, I would like ask for a help in one script I'm currently working on. Main goal is to compare size of file available on remote site and file already downloaded (check if downloaded file is complete and non corrupted). # Check if files were downloaded correctly for FILES in... (6 Replies)
Discussion started by: brusell
6 Replies

4. Shell Programming and Scripting

Arranging Haphazard output in readable format

Dear Friends, Need your help once again. I have a sql to download output in pipe separated format. Due to that output looks haphazard. E.G. $cat output.temp 123|456|789|0 67345123||3455|1 7124563|432343414||345324 By any was can we arrange it in tabular format for better... (4 Replies)
Discussion started by: anushree.a
4 Replies

5. Shell Programming and Scripting

Need Help in arranging the output

Hello All, Please find attached input and output files. I want to write a shell script to achieve this. I tried using awk but not getting how to do this as I am new to shell programming. Thanks (4 Replies)
Discussion started by: Sudeep Bhattad
4 Replies

6. Shell Programming and Scripting

Merge output of 2 commands into variable

I am extracting two pieces of information from the following file: /proc/cpuinfo, that I need to merge into one report. The first command: grep -i processor /proc/cpuinfo | awk '{print $1$2,$3}' yields: processor: 0 processor: 1 processor: 2 processor: 3 The second command: grep -i... (4 Replies)
Discussion started by: jamarsh
4 Replies

7. Solaris

Logging commands and output

I'm looking for a CLI utility that will capture all the commands you type at the Solaris CLI (and their output) into a file. I'm sure it's called "scripter", but I can't find anything on a command called scripter. Does anyone know of a such a command? Your help will be greatly... (3 Replies)
Discussion started by: soliberus
3 Replies

8. Shell Programming and Scripting

Combine Two Commands Output

How i can combine output of two commands in one file.......i tried this but it is not working although each command is working good seperately..... head -1 filename | tail -1 filename i think there is problem with command concatenator? (16 Replies)
Discussion started by: 33junaid
16 Replies

9. UNIX for Dummies Questions & Answers

Output of 2 commands into 1 file

How could you put the output of two commands into one file using a single command? For example put the output of a grep command and a sort command into one file together. Here is another rough explanation of what I am trying to do; output of $ grep pattern file1 plus output of $ sort file... (8 Replies)
Discussion started by: enuenu
8 Replies

10. UNIX for Advanced & Expert Users

Output all commands to logfiles ???

Dear Forum, My .cshrc settings are embedded in a massive jungle of code distributed all over the place, where finding anything is a "needle in a haystack" daily pain in the royal backside. Is there anyway, i can dump out every command and file executed to STDOUT after sourcing my .cshrc ??? ... (2 Replies)
Discussion started by: fawqati
2 Replies
Login or Register to Ask a Question