How to store count of multiple queries in variables in a shell script?

Thread Tools Search this Thread
Operating Systems Linux How to store count of multiple queries in variables in a shell script?
# 1  
Old 01-31-2014
How to store count of multiple queries in variables in a shell script?

how to store the count of queries in variables inside a filein shell script

my output :

variable1=result from 1st query
variable2=result from 2nd query
# 2  
Old 01-31-2014
Are you able to elaborate on your question?
# 3  
Old 01-31-2014
i wnat to store the count value from a query to a variable and then store the result in a file:

inside my result file my output should be:

variable1=result of query1(it will be a number)
variable2=result of query2(it will be a number)
# 4  
Old 02-03-2014
variable1=$("select count(*) from table") && echo "variable1="${variable1}"" >> file.txt

You should use the relevant flag on your SQL for suppressing column headers etc. If you are using DB2, the option is -x .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script count lines and sum numbers from multiple files

I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines: It counts the number of lines: egrep -i String file_name_201611* |... (5 Replies)
Discussion started by: Elly
5 Replies

2. Shell Programming and Scripting

Shell script to read a file and store in variables

I have a input file like this. Sample.txt 30 | TXDatacenter | TXBackupDC 10 | UKDatacenter | UKBackupDC 0 | NLDatacenter | NLBackupDC ...... ...... ...... I need to get these values in different variables like this. Load1=30 PriCenter1=TXDatacenter... (5 Replies)
Discussion started by: Visha
5 Replies

3. Shell Programming and Scripting

Executing Multiple Queries in parallel in Shell

I have n number of SQL queries needs to executed in Shell. Result of this query need to assign in a variable. Once all the queries are executed script needs to exit. Sample Query: SQL 1: Select Count(*) from TABLE GROUP BY COL1,COL2 SQL 2: Select Count(*) from TABLE GROUP BY COL1,COL2 ... (2 Replies)
Discussion started by: Niranjancse
2 Replies

4. Shell Programming and Scripting

How to store results of multiple sql queries in shell variables in ksh?

Hi, I have a script where I make a sqlplus connection. In the script I have multiple sql queries within that sqlplus connection. I want the result of the queries to be stored in shell variables declared earlier. I dont want to use procedures. Is there anyway else. Thanks in advance.. Cheers (6 Replies)
Discussion started by: gonchusirsa
6 Replies

5. Shell Programming and Scripting

Shell Script to store contents of multiple files into one

Hi, I"m writing a script to store all the contents of multiple files with different file names into one single file. I am giving in only last modified date of file in a folder. The below script gives a list of just one file based on the input date i give which is taken as string variable. I... (2 Replies)
Discussion started by: ashrocks
2 Replies

6. Shell Programming and Scripting

count multiple objects in shell script

Hi all: Trying to count the number of oracle instances on HPUX 11.23 - using ksh. I have multiple instances running and I would like to have a count for how many processes for each instance. Example, run the 'ps -efu oracle' command and for each instance increment a counter. So I am looking for... (4 Replies)
Discussion started by: raggmopp
4 Replies

7. Shell Programming and Scripting

store multiple variables in one go

Guys anyone know how i can store fields into multiple variables in one go? I'm wanting to grab the disk id's from format into disk1 and disk2 Below is what i want to work but i know it doesnt :- : | format | awk '/^(\ +)/ {print $2}' | read disk1 disk2 The below does work...but i don't... (5 Replies)
Discussion started by: lavascript
5 Replies

8. Shell Programming and Scripting

Multiple MySql queries in shell script?

Hi guys, i know how to run a single query using mysql embedded in a shell script as follows: `mysql -umyuser -pmypass --host myhost database<<SQL ${query}; quit SQL` However, how would i be able to run several queries within the same connection? The reason for this is i am creating... (3 Replies)
Discussion started by: muay_tb
3 Replies

9. Shell Programming and Scripting

How to store contents of a command in array of variables in shell script?

I want to store contents of command dir in array of variables For eg: dir contents are command d2 demovi~ file inven java new untitled folder d1 demovi er1 filename inven~ myfiles ubuntu desktop xmms ----------------------------------- I... (3 Replies)
Discussion started by: netresearch
3 Replies

10. Shell Programming and Scripting

How to store query multiple result in shell script variable(Array)

:) Suppose,I have one table A. Table A have one column. Table A have 10 rows. I want this 10 rows store into shell script variable. like #!/bin/ksh v_shell_var=Hi here in call oracle , through loop How can I store table A's 10 rows into v_shell_var (Shell Script Array). Regards, Div (4 Replies)
Discussion started by: div_Neev
4 Replies
Login or Register to Ask a Question