How to place the output of two different echo statements on one line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to place the output of two different echo statements on one line
# 1  
Old 11-20-2002
How to place the output of two different echo statements on one line

Hello there,

I wrote a shell script to modify the code for some of our clients in our client database. Before starting the data modification the program performs a few checks.

When a check is being performed, it should be shown on the screen of the user running the program, the result of the check should appear a few seconds later on the screen, on the same line.



for example.

.....
.....
.....
echo "Start check 1 for client" $1 ".........."


if [ check 1 = true ]
echo "OK"
else
echo "NOT OK"
exit
fi
.....
.....
.....


When I run my scripts, the result on the screen will be

$ data_modif.sh
Start check 1 for client A ..........
OK
$

What I would like it to be is
$ data_modif.sh
Start check 1 for client A..........OK
$

I have been trying for a few HOURS now to get the description of the check and the result of the check on the same line, but it seems hopeless.

Maybe someone can help me.
# 2  
Old 11-20-2002
Readup on the tput command.
Code:
man tput

With it you can move the cursor to a specific line on screen, and then "echo" from that point.

Failing that, I would recommend writing the script in another language which would allow more flexability in its output - Perl, for example.
# 3  
Old 11-20-2002
Re: How to place the output of two different echo statements on one line

Quote:
Originally posted by JoBa
When a check is being performed, it should be shown on the screen of the user running the program, the result of the check should appear a few seconds later on the screen, on the same line.
This is shell dependent. Most shells have echo built in, and you thus need to check the man page for the shell.

(Almost?) All systems also have an echo binary in /bin/echo, which may or may not have different options. F'rinstance on IRIX 6.5, /bin/echo changes its behavior based on an environment variable.

For many versions of echo, the following does what you want:
Code:
echo -n "Start check 1 for client" $1 ".........."

# 4  
Old 11-20-2002
Re: Re: How to place the output of two different echo statements on one line

Quote:
Originally posted by criglerj
For many versions of echo, the following does what you want:
Code:
echo -n "Start check 1 for client" $1 ".........."

And for the other versions of echo:
echo "Start check 1 for client $1 ..........\c"
should do it.

And you should be able to put $1 inside double quotes by the way.
# 5  
Old 11-20-2002
And check the print command in some shells which should have the -n option to forgo the NEWLINE.
# 6  
Old 11-20-2002
Thanks Perderabo,

The '\c' did the trick.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep echo awk print all output on one line

Hello, I've been trying to find the answer to this with Google and trying to browse the forums, but I haven't been able to come up with anything. If this has already been answered, please link me to the thread as I can't find it. I've been asked to write a script that pulls a list of our CPE... (51 Replies)
Discussion started by: rwalker
51 Replies

2. Shell Programming and Scripting

BASH - Need to echo for loop output to one line

I'm trying to echo the release version of some of our Linux servers. Typically I do these types of things by "catting" a text file with the host names, "ssh-ing" to the host and running my string. This is what I've written for i in `cat versions.txt` ; do echo $i ; ssh $i cat /etc/issue |... (5 Replies)
Discussion started by: lombardi4851
5 Replies

3. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies

4. Shell Programming and Scripting

Sftp : not able to print the echo statements after the sftp transfer

I had the below sftp script working perfectly but the problem is I am not able to send the echo statements . #!/bin/sh echo "Starting to sftp..." sftp admin@myip << END_SCRIPT cd /remotepath/ lcd /localpath/ mget myfiles*.csv bye END_SCRIPT echo "Sftp successfully." echo echo... (11 Replies)
Discussion started by: scriptscript
11 Replies

5. Shell Programming and Scripting

multiple echo statements in if condition

Hi , I have a peculiar problem. i have an if block like this if ; then echo " todays date is " ${date} >> log_file echo " file count is " $ count >> log_file mv filename1 filename 2 else echo "no files available ">> log_file fi the echo statement "no files available " is not... (2 Replies)
Discussion started by: wizardofoz
2 Replies

6. Shell Programming and Scripting

echo two command output in the same line

Hi, I try to write script and echo two command at the same line . echo "A" echo "B" How can I pipe above two command at the same line in text file . So, in the output text file , you can see below ??? A B not A B Any sugggestion ??? (4 Replies)
Discussion started by: chuikingman
4 Replies

7. Shell Programming and Scripting

howto place in one line output from two functions

Hi I would like to place in one line output from two functions. Both functions return text with print cmd. When I place above code in script it will place them in series. e.g. 1 #/bin/ksh 2 3 function1() 4 { 5 print "My name is" 6 ... (3 Replies)
Discussion started by: presul
3 Replies

8. Shell Programming and Scripting

Echo and a command's output on the same line

Hello, I'm writing some bash scripts and I'm trying to get an echo command and the output of another command to display on the same line. For example: I want to run echo "Operating System: " unameand have it displayed as Operating System: Darwin Thanks for your help! (7 Replies)
Discussion started by: codyhazelwood
7 Replies

9. Shell Programming and Scripting

Output of both the echo statement in one line

I have script like echo -n FINISHED FEXP: ${TABLE2EXP} echo $STATUS I want the output of both the echo statement in one line How can i do this (3 Replies)
Discussion started by: scorp_rahul23
3 Replies

10. Shell Programming and Scripting

How to write multiple echo statements in unix?

How to write multiple echo statements in unix? echo "************************************************************************************************************"; echo This Script do the following functions echo 1. Point 1 echo 2. Point 2 echo 3. Point 3 echo... (2 Replies)
Discussion started by: Shrutiduggal
2 Replies
Login or Register to Ask a Question