Problems with one line output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problems with one line output
# 1  
Old 01-07-2013
Problems with one line output

my echo $var1 gives below value


Code:
Code:
1.7_NEW=25,1.7_RETAINED=30,1.7_RETURNING=40

i want it in 3 different values....

i.e. as


Code:
Code:
echo $1.7_NEW=25
echo $1.7_RETAINED=30
echo $1.7_RETURNING=40



the o/p of $1.7_NEW should be 25.....
# 2  
Old 01-07-2013
You cannot assign variables named with numbers
i.e.;

Code:
a=somevalue
1.7_NEW=25  # this will generate an error.

So, could you show us what your input data looks like, so we can help you get output?
# 3  
Old 01-07-2013
hi jim

I did try the same.... but i did get error...
so i taut of asking help from this forum...

m getting this var1 value from DB with a simple select query....
# 4  
Old 01-07-2013
Quote:
Originally Posted by nikhil jain
the o/p of $1.7_NEW should be 25.....
What are you about to perform with these variables ?
# 5  
Old 01-07-2013
Code:
echo "$var1" |  awk -F[,=] '{print $2, $4, $6 } '

Start with that, and if you were to explain what you need rather than what you did, we could help more.
# 6  
Old 01-07-2013
Hi Nikhil,

I am assuming this this varibale is coming from a script, where you are trying to fetch data from a database. In case you ment to see the variables in different lines rather online We can use 'tr' command, hope this helps.

Code:
[Rob@mytestmachine~]# echo $var1|tr '[,]' '[\n]'
1.7_NEW=25
1.7_RETAINED=30
1.7_RETURNING=40

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

3. Shell Programming and Scripting

Problems with awk printf, formatted output

Hi, i have a script, which is incomplete, am on my way developing it. Input 1,12,2012,IF_TB001 2,12,2012,3K3 3,Z56,00000,25,229,K900,00, ,3G3, ,USD, ,0000000000,000, , , , 550000000 3,Z56,00000,53,411,W225,00,000, , ,USD,OM170,0000000000,000, , , , -550000000 4,Z56,COUNT, 4,SUM LOC,... (19 Replies)
Discussion started by: selvankj
19 Replies

4. Shell Programming and Scripting

Converting line output to column based output

Hi Guys, I am trying to convert a file which has a row based output to a column based output. My original file looks like this: 1 2 3 4 5 6 1 2 3 1 2 3 (8 Replies)
Discussion started by: npatwardhan
8 Replies

5. Shell Programming and Scripting

My output Problems

jnkjhjkhbjkhb (1 Reply)
Discussion started by: vinayrao
1 Replies

6. Shell Programming and Scripting

problems getting a segment from a string output

Hi I'm creating a script that creates files from svn checkout and compress them using tar.gz the script gets the repository name from command line argument i need to capture a number from the last line of the output and create a file name from it. the svn returns output of all the file... (5 Replies)
Discussion started by: tzvio
5 Replies

7. UNIX for Advanced & Expert Users

Help please...output problems with printf.

#include <stdio.h> #include <math.h> // this function calculates the volume of a Cylinder int main(void) { int r; // radius int h; // height double M_PI; // pi int pOne = pow (r, 2); // get user input of radius and height printf ("Enter your... (3 Replies)
Discussion started by: pwanda
3 Replies

8. Shell Programming and Scripting

how to make a line BLINKING in output and also how to increase font size in output

how to make a line BLINKING in output and also how to increase font size in output suppose in run a.sh script inside echo "hello world " i want that this should blink in the output and also the font size of hello world should be big .. could you please help me out in this (3 Replies)
Discussion started by: mail2sant
3 Replies

9. AIX

Man command doesn't display any output amonst other problems

hi all, Newbie to Unix and AIX. So my apologies if this is in the wrong place, etc. Working on box - uname# uname -a AIX appt 3 5 00C08AAF4C00 when i type man (some valid command) it just returns me to the # prompt. Its running on the KSH shell. man was working but i was trying... (6 Replies)
Discussion started by: djdavies
6 Replies

10. UNIX for Dummies Questions & Answers

Man command doesn't display any output amonst other problems :-)

hi all, Newbie to Unix and AIX. So my apologies if this is in the wrong place, etc. Working on box - uname# uname -a AIX appt 3 5 00C08AAF4C00 when i type man (some valid command) it just returns me to the # prompt. Its running on the KSH shell. man was working but i was trying... (14 Replies)
Discussion started by: djdavies
14 Replies
Login or Register to Ask a Question