It is currently Sat, 04 Feb 2023 12:49:24 GMT



 
Author Message
 Formattet output inside variable / line brak inside variable
Hi everybody,

i am using the tcsh under freebsd

i want query a mysql DB wich have approx 100 entrys and generate
multiple template files.

The problem is that the direct output to a variable doesnt work there
are differences between the output into a text file and a variable.

I don't want to use a text file for data generation.

is there any possibility to preformat the variable input in that form
that i can do an echo $variable and get an output like sample OUTPUT2 ?

Regards Michael

-- Output1: directly at a tcsh
host01:/home/ux/mytest> host01:/home/ux/mytest> echo "select
id,nr,color,length,type,count(length) from patch.cable  group by
length,type,color;" | mysql -ur -pr -B

id      nr      color   length  type    count(length)
032     132     grey    1000    std     6
020     120     grey    2000    std     12
001     100     grey    3000    std     13

Output2: generated in a tcsh and written to a file

host01:/home/ux/mytest>  echo "select
id,nr,color,length,type,count(length) from patch.cable  group by
length,type,color;" | mysql -ur -pr -B > test1.txt

host01:/home/ux/mytest> less test1.txt
id      nr      color   length  type    count(length)
032     132     grey    1000    std     6
020     120     grey    2000    std     12
001     100     grey    3000    std     13

Output3 generated in a tcsh and written to a variable

host01:/home/ux/mytest> set test125=`echo "select
id,nr,color,length,type,count(length) from patch.cable  group by
length,type,color;" | mysql -ur -pr -B`

host01:/home/ux/mytest> echo $test125
id nr color length type count(length) 032 132 grey 1000 std 6 020 120
grey 2000 std 12 001 100 grey 3000 std 13



 Sun, 07 Dec 2008 19:38:23 GMT   
 Formattet output inside variable / line brak inside variable

Always use

echo "$variable"

--
Michael Tosch @ hp : com



 Sun, 07 Dec 2008 20:10:35 GMT   
 Formattet output inside variable / line brak inside variable

csh/tcsh also treat the `backticks` wrong.
Use sh instead:

x=`ls`
echo "$x"

works as expected only in sh,ksh,bash,...

--
Michael Tosch @ hp : com



 Sun, 07 Dec 2008 20:18:47 GMT   
 Formattet output inside variable / line brak inside variable

hmm this is not helpful the problem should be the input fotmat -  i want
inoput data from mysql to a variable



 Mon, 08 Dec 2008 15:27:12 GMT   
 Formattet output inside variable / line brak inside variable

I thought you've got the idea.
Mapping the idea to your case:

#!/bin/sh
test125=`echo "select id,nr,color,length,type,count(length) from patch.cable  group by length,type,color;" | mysql -ur
-pr -B`
echo "$test125"

--
Michael Tosch @ hp : com



 Tue, 09 Dec 2008 00:29:35 GMT   
 
   [ 5 post ] 

Similar Threads

1. Evaluate a variable that is inside a string variable

2. variable inside of variables

3. Problem: Shell Variable inside Variable ????

4. To use Environment Variable inside java

5. Global variables inside shared library on Solaris

6. substitute sh shell command inside variable

7. HELP: Bash problem expanding variable inside condition...

8. variable in awk inside csh script

9. grepping for pattern with variable inside


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software