How to avoid new line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to avoid new line
# 1  
Old 08-24-2011
MySQL How to avoid new line

Hi,

I am having multiple echo statements to print output
echo "$VAr"
echo "$lenght"
echo "$sum"

I get the output as
12
24
36

I need the output to be 12 24 36.

How do i arrive at this.

Thanks in advance
# 2  
Old 08-24-2011
Code:
$ echo "$Var $lenght $sum"

# 3  
Old 08-24-2011
Hi krashraj,
Use -n option in echo command
Code:
echo -n "$VAr"
echo -n "$lenght"
echo -n "$sum"

With Regards,
Raj.
# 4  
Old 08-24-2011
Thanks for the kindly reply for a straight forward solution which i could not get .
# 5  
Old 08-24-2011
Since you are printing numbers you can have more control over precision and formatting if needed by using printf if your shell supports it:
Code:
printf "%f %d %d\n" $var $length $sum

This page has great info and examples for the korn shell, scroll down a little to the printf section.
String I/O (Learning the Korn Shell, 2nd Edition)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Avoid printing entire line if string not found

so im searching the process table with: ps -ef | awk -F"./rello.java" '{ print substr($0, index($0,$2)) }' I only want it to print everything that's infront of the "./rello.java". That's because im basically getting the arguments that was passed to the rello.java script. this works. ... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

How to avoid the spaces?

Hi I have a script which runs the isql command and takes the output in a xls file. Is there a way to trim the spaces(leading and trailing) from all the values in the column of the xls sheet? (6 Replies)
Discussion started by: Sharma331
6 Replies

3. Shell Programming and Scripting

Avoid single line output from function

I am new to shell scripting and wished to get few things clarified. While calling functions within shell script, output comes out as single line irrespective of the no of echos or newlines I tried within function + the echo -e used to invoke function ( as instructed online) : #!/bin/sh inc() {... (1 Reply)
Discussion started by: RMath
1 Replies

4. Shell Programming and Scripting

How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code while read line do echo $line done < example content of example file sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the output is like sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the... (4 Replies)
Discussion started by: Kesavan
4 Replies

5. Shell Programming and Scripting

Plz Help-how to avoid blank next line

Hi, I want to pick the latest file name and save it in a file. later i'll be insert this file name in a oracle table.But i m getting a strange issue. while putting the file name to a file, some extra blank line also coming to that file.i m using cmd.... ls -t *_xxx_*.dat head - 1 > yyy.csv In... (5 Replies)
Discussion started by: palash
5 Replies

6. Shell Programming and Scripting

Need to avoid empty line error

Hi, Below shell script executes based on liasted data files parameters.But small problem need to avoid ,If any empty line occures in dat files it's throwing oracle error .Need to ignore empty lines (means does not ready by script).Please advice. #/bin/sh adsts=`cat... (2 Replies)
Discussion started by: krajasekhar.v
2 Replies

7. Shell Programming and Scripting

how to avoid new line characters

Hi, I am using gzip command to compress the files at the UNIX server and FTP ing it in Binary mode to Windows server.(If ASCII mode is used im getting the output as junk characters) When i extract the files at Windows server a new line character is getting appended to the output file which is not... (4 Replies)
Discussion started by: Codesearcher
4 Replies

8. Shell Programming and Scripting

How to avoid the space

Hi, I have some problem with following command. $path='pwd'.”/pack”; When I check the value in the variable path , it give the following output /tmp/new /pack The pwd will be /tmp/new Now the problem is the spaces is added between pwd and the appended path. I need the output like... (5 Replies)
Discussion started by: kalpeer
5 Replies

9. UNIX for Advanced & Expert Users

How to avoid polling???

Hi all, I have a directory where some process is keeping incremental/new log files. I need to code a program which will periodically poll this directory and if it founds a new file arrived then copy that new file to some other specific directory. We are OK with this polling approach. I just... (3 Replies)
Discussion started by: zing_foru
3 Replies
Login or Register to Ask a Question