printing two values with TAB in between


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting printing two values with TAB in between
# 1  
Old 11-30-2010
printing two values with TAB in between

Dear friends,
I want to print variables' values in certain format where space between two values of variables is "a tab"

I tried where I provided "tab" between two varibales.
But when it print values on screen its giving me output without spaces in two values.

Request you to help me in guiding me.
Thanks,
Anushree.
# 2  
Old 11-30-2010
Code:
var1="hello"
var2="world"
echo -e "$var1\t$var2"

# 3  
Old 11-30-2010
Thank you Kevintse for the quick help.
I tried the solution its giving me desired output but it has "-e" at the starting of line.
e.g.
-e rem renn red redd
-e is not expected in output.
Please help.
Anushree.
# 4  
Old 11-30-2010
Your probably using the ksh shell (not bash) so -e option isn't required, just drop it.

If no luck you can also try:

Code:
var1="hello"
var2="world"
echo "$var1\011$var2"


Last edited by Chubler_XL; 11-30-2010 at 01:27 AM..
# 5  
Old 11-30-2010
Code:
var1="hello"
var2="world"
/bin/echo -e "$var1\t$var2"

# 6  
Old 11-30-2010
ilikecows, this dosn't work on AIX (or Solaris I think).
\
Code:
$ /bin/echo -e "test\ttest"
-e test test

# 7  
Old 11-30-2010
Quote:
Originally Posted by anushree.a
Dear friends,
I want to print variables' values in certain format where space between two values of variables is "a tab"

I tried where I provided "tab" between two varibales.
But when it print values on screen its giving me output without spaces in two values.

Request you to help me in guiding me.
Thanks,
Anushree.
put quotes around the values you need to print as such
Code:
echo 'My        World'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk printing leading tab in output

The awk below executes and produces the current output. it skips the header in row 1 and prints $4,$5,$6 and then adds the header row back. The problem is that it keeps the tailing tab and prints it in front of $1. I could add a pipe to remove the tab, but is there a better way to do it with on... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. Shell Programming and Scripting

Printing $values using awk

Hi All I had requirement where I need to re-order columns in a file by using a control file. here is the ctrl file c1 c2 c3 source file c3 | c1 | c2 a | b| c I should create output file based on the ctrl file columns o/p should look like this c1 | c2 | c3 b| c|a I wrote some... (9 Replies)
Discussion started by: gvkumar25
9 Replies

3. UNIX for Dummies Questions & Answers

Sort tab delimited file according to which rows have missing values

Hello! I have a tab delimited file with values in three columns. Some values occur in all three columns, other values are present in only one or two columns. I would like to sort the file so that rows with no missing values come first, rows with one missing values come next, and rows with two... (9 Replies)
Discussion started by: MBarrett1213
9 Replies

4. Programming

Printing values from a class

I have a class and want to print values in MOD using L = new Layer* ; How can I print the values in MOD using this object L??? class Layer { public : Model* MODP; Model* MODS; (1 Reply)
Discussion started by: kristinu
1 Replies

5. Programming

Printing float values in C

Hi, I have small problem to print float value in the fallowing code float Cx, W,f=250000, Cr=92.00,pi=3.14; W=2*pi*f; Cx = 1/W.Cr; //Cx value will be come around like 7.07E-9. printf("capacitance value: %.10f",Cx); I am trying to print Cx value using above code but it was not... (3 Replies)
Discussion started by: veerubiji
3 Replies

6. UNIX for Dummies Questions & Answers

How to echo space or tab delimited values into rows?

Hi, I have the following code: LIST=`ls | grep '.sql$'` echo $LIST The above code will give me something like.. file1.sh file2.sh file3.sh file4.sh file5.sh I want to display the values into rows using echo like... file1.sh file2.sh (5 Replies)
Discussion started by: adshocker
5 Replies

7. Shell Programming and Scripting

search file and group values with problematic tab

hi people; the similar topic is being opened in here and here but i have confused with following condition. so i wanted to open a seperate topic. from my file.txt:... ... ... 110105-16:04:04 192.168.1.1 7.1j Port_NODE_MODEL_M_1_8 stopfile=/tmp/10544... (0 Replies)
Discussion started by: gc_sw
0 Replies

8. Shell Programming and Scripting

Retrieving values from tab-delimited file in unix script

Hi I am trying to retrieve values from a tab-delimited file.I am using while read record value=`echo $record | cut -f12` done Where 12 is the column no i want retieve and record is one line of the file. But it is returning the full record. Plz help (4 Replies)
Discussion started by: akashtcs
4 Replies

9. Shell Programming and Scripting

a tab between values

Hi, I have a file that looks like this: 36- 9+ 45- 43+ 400- 700+ I want to put a space between the number and the -/+ sign. So the output file will look like this 36 - 9 + 45 - 43 + 400 - 700 + (3 Replies)
Discussion started by: kylle345
3 Replies

10. UNIX for Dummies Questions & Answers

Printing problem - Vertical Tab

At work, when I issue: lpr -P$PRINTER -h filename the file always prints a line then does a vertical tab off that first line instead of starting the new line at left. It does this with every file I've tried, and I can't find any options that are set that would make things print this way. I... (2 Replies)
Discussion started by: scaredinjuly
2 Replies
Login or Register to Ask a Question