Print in single line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print in single line
# 1  
Old 09-13-2013
Print in single line

HI
I am having a flle like below .

test.txt

Code:
 
ssh aaaaaaa@bbbbbbbbb "head -1 /xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd"
echo /xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd
ssh aaaaaaa@bbbbbbbbb "head -1 /xxxxxx/yyyyyyy/yyyyyyy.sp.xreff_upd_gm"
echo /xxxxxx/yyyyyyy/yyyyyyy.sp.xreff_upd_gm


when i do
Code:
 
sh test > result3

i am getting out put created as follows

Code:
IMAHDR cccccc01 ISSUER 20130418 20130418 001
/xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd
IMAHDR cccccc01 XREFF 20130228 20130228 001
/xxxxxx/yyyyyyy/yyyyyyy.sp.xreff_upd_gm

BUt i want first 2 command output in one single line .something like the following

Code:
 
IMAHDR cccccc01 ISSUER 20130418 20130418 001 /xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd
IMAHDR cccccc01 XREFF 20130228 20130228 001 /xxxxxx/yyyyyyyyyyyyyy.sp.xreff_upd_gm


Last edited by Scrutinizer; 11-05-2015 at 03:48 AM.. Reason: Use CODE tags, not ICODE tags, for code blocks, please...
# 2  
Old 09-13-2013
Code:
ssh aaaaaaa@bbbbbbb "head -1 /xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd | xargs printf %s" && echo " /xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd"


Last edited by Scrutinizer; 11-05-2015 at 03:49 AM..
# 3  
Old 09-14-2013
This is one way:
Code:
rv1=`ssh aaaaaaa@bbbbbbbbb "head -1 /xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd"`
rv2=`ssh aaaaaaa@bbbbbbbbb "head -1 /xxxxxx/yyyyyyy/yyyyyyy.sp.xreff_upd_gm"`
echo "$rv1 /xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd"
echo "$rv2 /xxxxxx/yyyyyyy/yyyyyyy.sp.xreff_upd_gm"


Last edited by Scrutinizer; 11-05-2015 at 03:49 AM..
# 4  
Old 09-14-2013
Code:
f1=/xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd
f2=/xxxxxx/yyyyyyy/yyyyyyy.sp.xreff_upd_gm
cat << EOF
$(ssh aaaaaaa@bbbbbbbbb "head -1 $f1") $f1
$(ssh aaaaaaa@bbbbbbbbb "head -1 $f2") $f2
EOF

or
Code:
f1=/xxxxxx/yyyyyyy/yyyyyyy.sp.issuer_upd_fd
f2=/xxxxxx/yyyyyyy/yyyyyyy.sp.xreff_upd_gm
printf "%s\n" "$(ssh aaaaaaa@bbbbbbbbb "head -1 $f1") $f1"
printf "%s\n" "$(ssh aaaaaaa@bbbbbbbbb "head -1 $f2") $f2"


Last edited by Scrutinizer; 11-05-2015 at 03:51 AM..
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. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

3. Shell Programming and Scripting

Multiple pattern match and print the output in a single line

I need to match two patterns in a log file and need to get the next line of the one of the pattern (out of two patterns) that is matched, finally need to print these three values in a single line. Sample Log: 2013/06/11 14:29:04 <0999> (725102) Processing batch 02_1231324 2013/06/11... (4 Replies)
Discussion started by: rpm120
4 Replies

4. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

5. Shell Programming and Scripting

Find 2 expressions then print in a single line

Guys, need help. I have a file that contains something like this: abc def ghi jkl I want to print the first and last line of the file and the output should be in a single line. so, output should be like this: abc jkl (3 Replies)
Discussion started by: solidhelix08
3 Replies

6. Shell Programming and Scripting

Print (echo) variable in a single line

Hi, I have written this code ------------------------------------------------ # !/bin/ksh i=0 while do j=$i while do echo -e $j #printf "%d",$j j=`expr $j - 1` done echo i=`expr $i + 1` done ---------------------------------------------------- The ouput which... (2 Replies)
Discussion started by: rac
2 Replies

7. Shell Programming and Scripting

Perl question - How do I print contents of an array on a single line?

I have the following code: print @testarray; which returns: 8 8 8 9 How do I return the array like this: The output is: 8, 8, 8, 9 (5 Replies)
Discussion started by: streetfighter2
5 Replies

8. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

9. Shell Programming and Scripting

How to print the output in single line

Hi, Please suggest, how to get the output of below script in single line, its giving me in different lines ______________________ #!/bin/ksh export Path="/abc/def/ghi"; Home="/home/psingh/prat"; cd $Path; find $Path -name "*.C#*" -newer "abc.C#1234" -print > $Home cat $Home | while... (1 Reply)
Discussion started by: Prat007
1 Replies

10. 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
Login or Register to Ask a Question