Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Storing the output into a variable Post 302099051 by ravi raj kumar on Friday 8th of December 2006 06:44:46 AM
Old 12-08-2006
Smilie Ok,fine .Its working.But when i am trying to use the result in another calculation its not giving the proper result.
x='hello'
y=$(echo $x | wc -c)
echo $y
z='expr $y + 1 '
echo $z

Its printing expr $y + 1 instead of 7. Smilie

any idea pls.



cheers
Ravi Raj kumar
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

storing output of awk in variable

HI I am trying to store the output of this awk command awk -F, {(if NR==2) print $1} test.sr in a variable when I am trying v= awk -F, {(if NR==2) print $1} test.sr $v = awk -F, {(if NR==2) print $1} test.sr but its not working out . Any suggestions Thanks Arif (3 Replies)
Discussion started by: mab_arif16
3 Replies

2. Shell Programming and Scripting

Using 'defaults read' and storing the output in a variable

Hi all, I'm creating a script which uses 'defaults read' to retrieve details from an Info.plist like this; defaults read "/Path/Contents/Info" CFBundleShortVersionString This works fine in Terminal and returns the expected values. Is it possible to use this command in a script, and... (0 Replies)
Discussion started by: davewg
0 Replies

3. UNIX Desktop Questions & Answers

problem while storing the output of awk to variable

Hi, i have some files in one directory(say some sample dir) whose names will be like the following. some_file1.txt some_file2.txt. i need to get the last modified file size based on file name pattern like some_ here i am able to get the value of the last modified file size using the... (5 Replies)
Discussion started by: eswarreddya
5 Replies

4. UNIX for Dummies Questions & Answers

Storing lines of output into a script variable

I'm sure this is a simple thing but I can't figure it out. In a script that I'm writing, I'd like to be able to store each line of output from "ls -l" into a variable. Ultimately I'd like to end up with something like: for a in `ls -l` do something with $a doneBut that's reading each... (2 Replies)
Discussion started by: ewoods
2 Replies

5. Shell Programming and Scripting

storing output from echo & cut into variable

Hi All, Hope someone can advise here as I have been struggling to find a syntax that works here. I have tried a stack of combination I have seed in the forums but I think because I have needed to use "" and `` in the statments another method is found. I am reading in lines with the following... (1 Reply)
Discussion started by: nkwilliams
1 Replies

6. Shell Programming and Scripting

Storing output of "time" command to a variable

Hi all, I am new to Linux/shell scripting having moderate knowledge. In my script, I need to get execution time of a command (say 'ls') in mili seconds level. For this i tried using "time" command to retrieve the total execution time in milli seconds. But, the problem is that, how to save... (9 Replies)
Discussion started by: happening_linux
9 Replies

7. Shell Programming and Scripting

Storing output into a variable

My script below seems to be choking because I need the the output of the find command to be stored as a variable that can then be called by used lower in the script. #!/bin/bash cd "/resumes_to_be_completed" var1=find . -mmin -1 -type f \( -name "*.doc" -o -name "*.docx" \)... (1 Reply)
Discussion started by: binary-ninja
1 Replies

8. Shell Programming and Scripting

Storing command output in a variable and using cut/awk

Hi, My aim is to get the md5 hash of a file and store it in a variable. var1="md5sum file1" $var1 The above outputs fine but also contains the filename, so somthing like this 243ASsf25 file1 i just need to get the first part and put it into a variable. var1="md5sum file1"... (5 Replies)
Discussion started by: JustALol
5 Replies

9. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

10. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies
DBX_FETCH_ROW(3)							 1							  DBX_FETCH_ROW(3)

dbx_fetch_row - Fetches rows from a query-result that had the DBX_RESULT_UNBUFFEREDflag set

SYNOPSIS
mixed dbx_fetch_row (object $result_identifier) DESCRIPTION
dbx_fetch_row(3) fetches rows from a result identifier that had the DBX_RESULT_UNBUFFERED flag set. When the DBX_RESULT_UNBUFFERED is not set in the query, dbx_fetch_row(3) will fail as all rows have already been fetched into the results data property. As a side effect, the rows property of the query-result object is incremented for each successful call to dbx_fetch_row(3). PARAMETERS
o $result_identifier - A result set returned by dbx_query(3). RETURN VALUES
Returns an object on success that contains the same information as any row would have in the dbx_query(3) result data property, including columns accessible by index or fieldname when the flags for dbx_query(3) were set that way. Upon failure, returns 0 (e.g. when no more rows are available). EXAMPLES
Example #1 How to handle the returned value <?php $result = dbx_query($link, 'SELECT id, parentid, description FROM table', DBX_RESULT_UNBUFFERED); echo "<table> "; while ($row = dbx_fetch_row($result)) { echo "<tr> "; foreach ($row as $field) { echo "<td>$field</td>"; } echo "</tr> "; } echo "</table> "; ?> SEE ALSO
dbx_query(3). PHP Documentation Group DBX_FETCH_ROW(3)
All times are GMT -4. The time now is 08:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy