shell output on same line

Hi,

I think I did this before. How do you make the result from the shell call on the same line. e.g.

do shell script "(echo hello; echo goodbye)"

→ “hello
goodbye”
Instead of the results being on separate lines, have them on the same line.

thanks,
kel

Hello.

echo -n shouldn’t put out a new line after it has output its argument.

Hi McUsr,

do shell script "(echo -n hello; echo goodbye)"

didn’t work. But I was thinking of a more generic way. If you didn’t think of it by now it probably doesn’t exist, I think.

That’s ok. At least I have the two outputs.

Thanks anyway,
kel

It’s a known bug in the built-in echo command, you need to use the echo in /bin but that version doesn’t support the -e option.

do shell script "(/bin/echo -n hello; /bin/echo goodbye)"

What I was thinking was that you make all the shell script calls at the same time as much as possible. Sometimes you can’t do that because one call might need data from another call. Then ou don’t need to make as much shell calls.

Hi. Quotes and \c.

do shell script "echo 'hello \\c'; echo 'goodbye'"

Hi DJ Bazzie Wazzie,

It worked! /bin … How do you guys get these things? :cool:

Thanks a lot!
kel

What does the c\ stand for?

Edited: and there’s a space in between.

I wonder if it will work with parallel processes.

Because I asked myself the same question when I came from Mac OS to Mac OS X and using do shell scripts. Then reading man pages to find solutions. I also had experience in Bash before I first used Mac OS X did. So the key is that we’ve all been there but some a decade ago, others today and some tomorrow :wink:

coalescing the above notes, and testing:
Two methods:

(1) \c works, but only with /bin/echo

do shell script "/bin/echo 'hello \\c'; echo 'goodbye'"

(2) -n works, with either echo

do shell script "echo -n 'hello '; echo 'goodbye'"
do shell script "/bin/echo -n 'hello '; echo 'goodbye'"

[Tiger, AS 1.10.7]

Hi mhfadams,

Thanks for the great summary. One thing this one didn’t work for me:

do shell script "echo -n 'hello '; echo 'goodbye'"

Thanks,
kel

Model: MBP
AppleScript: AS 2.2.4
Browser: Safari 536.28.10
Operating System: Mac OS X (10.8)

This is known in the built-in version of echo in bash, like I said before. You can either use the \c at the end of string (for built-in echo command) or use the option -n for the echo command in your bin folder.

Thanks – now I understand: built-in echo vs. separate echo command.
I missed that distinction in your prev. post. Sorry.

That explains the ‘\c’ method compatibility,
but why does the ‘-n’ method work for me (built-in echo) but not for Kel1 ?

If it’s the built in version of bash that is working it could be that you’re using a different (fixed) version of bash.

do shell script "echo $BASH_VERSION"

My bash returns 3.2.48(1)-release, it’s shipped with the latest version of Snow Leopard.

I see now. The bug is in the bash built-in ‘echo’. Keeping the output on the same line needs the /bin/echo. Both methods don’'t work without the bin.

Thanks,
kel