The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Assign o/p of awk to a variable c2b2 Shell Programming and Scripting 8 04-01-2009 07:50 AM
assign a value to a variable Shivdatta Shell Programming and Scripting 10 01-17-2007 07:40 AM
assign value to variable using AWK HAA Shell Programming and Scripting 4 12-06-2006 11:43 AM
hot to assign output to a variable walnut Shell Programming and Scripting 1 02-22-2006 09:19 PM
assign to variable AkumaTay UNIX for Dummies Questions & Answers 1 05-18-2002 02:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2006
markjason markjason is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 14
assign a value to variable

I have to assign a result of a query to a vairable like this

how can i do this

Query = select count(*) from table
x=`db2 ${Query}| sed -n '4p'`

but this doesn't work, is there any other way to assign the result without redirecting the result to temp file. .

Thanks
Mark.
  #2 (permalink)  
Old 10-10-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
What shell are you using?
  #3 (permalink)  
Old 10-10-2006
markjason markjason is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 14
i am using ksh
  #4 (permalink)  
Old 10-10-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
I'm no db2 expert, but try this:
Code:
#!/bin/ksh

Query='select count(*) from table'
x=$(db2 "${Query}"| sed -n '4p')
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0