1833386 Members
3387 Online
110052 Solutions
New Discussion

Scripting - Printing

 
SAM_24
Frequent Advisor

Scripting - Printing

Hi,

I have output like this
detail1
detail3
detail4

I want to print above output like
echo "Want to print : detail1
detail2
detail3"

I am trying to achieve with whatever scripting I know but I got the output like

echo "Want to print : detail1
detail2
detail3"

Any help is appreciated.

Thanks.
Never quit
4 REPLIES 4
Systeemingenieurs Infoc
Valued Contributor

Re: Scripting - Printing

i'm not sure i understand your question, but try this :

program_tat_generates_output|
awk '{ printf "Want to print : %s\n", $0}'
A Life ? Cool ! Where can I download one of those from ?
V. V. Ravi Kumar_1
Respected Contributor

Re: Scripting - Printing

hi,
i could not understand what exactly u want. but if ur program runs in a loop every time it generates output like
first run
detail1
second run
detail2 ....etc.,

u assign this output to a variable like

tmp=`out put of program`

then in the next line in the loop write

echo "Want to print:$tmp"

Redirect the output of above echo statement to a file if u want.

Regards
Never Say No
Francisco J. Soler
Honored Contributor

Re: Scripting - Printing

Hi,
try with \n inside the echo command:

echo "Want to print:\ndetail1\ndetail3\ndetail4"


Frank.
Linux?. Yes, of course.
John de Villiers
Frequent Advisor

Re: Scripting - Printing

if you want to have them print next to each other then use \c at the end of each line as opposed to the assumed \n

John