Store o/p of awk in a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Store o/p of awk in a variable
# 1  
Old 09-20-2010
Store o/p of awk in a variable

Hi ,

Here is my script
Code:
echo 'Enter MSISDN for the Calling Number'
read ms
acc=`sqlplus -s testing/testing123@BP_$ARBORENV<<EOF
set heading off;
set feedback off;
select external_id from external_id_equip_map where subscr_no = (select subscr_no from external_id_equip_map where account_no = '$ms' and rownum<=1)  and external_id_type in ( '10', '11');
#select to_char($ms) from dual;
quit;
EOF`


what I want to do is to store the values $1 and $2 into variable
Code:
echo   $acc | awk '{print $1}'
echo   $acc | awk '{print $2}'

Please let me know how to

Last edited by pludi; 09-20-2010 at 09:25 AM.. Reason: code tags, please...
# 2  
Old 09-20-2010
How about?
Code:
variable1=$( echo "$acc"  | awk '{print $1}' )
variable2=$( echo "$acc"  | awk '{print $2}' )

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to store file name in a variable?

Hi All, Daily I am generating a file dfm_daily_file_ ex: dfm_daily_file_05072015 date will be changed daily. Once the file is FTP it is deleted. I have tried the below code to get the file name with any date and store it in a variable its not working. #!/bin/ksh ... (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies

2. Shell Programming and Scripting

Store ^M character in variable

Hi, I want to store ^M character in a variable to be later written to a file. Can you please help. TempOut="$_var1 `print '\x0D'` $_var1" ..... .... echo $TempOut >> logfile TempOut="$_var1 `echo -e '\x0D'` $_var1" ..... .... echo $TempOut >> logfile But both ways I am... (2 Replies)
Discussion started by: tostay2003
2 Replies

3. Shell Programming and Scripting

I can't store value in the variable

!#bin/bash clear var= grep @gmail.com email.txt | wc -l echo $var echo $var exit 0 OUTPUT: 1000 _ _ Where _ represent space (no value or nothing) (4 Replies)
Discussion started by: Muhammad Rehan
4 Replies

4. Shell Programming and Scripting

how to store output to a variable

I need some help: 1) I have a out put from a shell script, the out put looks like this: Attempting privilege escalation using sudo ... List backups for CLTST: Start date Status Ret. Class Label -------------------- ------------ ------------ ... (2 Replies)
Discussion started by: samk
2 Replies

5. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

6. UNIX for Dummies Questions & Answers

Using GREP/AWK to extract a number and store it as a variable

Hello, I have a question regarding the awk command. Here is the line I need to grep: 1 F= -.13250138E+03 E0= -.13249556E+03 d E =-.174650E-01 mag= 35.2157 Instead of displaying the number in red I would like to store it as a variable such as X. Is there a way to do this? Thanks for any... (3 Replies)
Discussion started by: modey3
3 Replies

7. Shell Programming and Scripting

store timestamp in a variable

I am new to Unix shell Script _________________________ db2 connect to r2pdev user bmwdevup using summer08 >>$monlog # get the current timestamp from SYSIBM.SYSDUMMY1 currenttimestamp="" echo "Run SQL select current timestamp from SYSIBM.SYSDUMMY1 with ur" >>$monlog db2 "select current... (8 Replies)
Discussion started by: regnumber
8 Replies

8. UNIX for Dummies Questions & Answers

How to Store command O/P to a variable...

Hi all.. I got a problem.. Its easy to redirect o/p to a file.. But Is it possible to redirect the O/P to a variable? For example: I've a command in my script: string1=cut -d ':' -f2 file.txt When I do: echo $string1 The value is empty... Pls suggest me how to store the value... (7 Replies)
Discussion started by: smartbuddy
7 Replies

9. Shell Programming and Scripting

To store the output in a variable

Hi, I am getting the following error while executing the script. Please can someone throw some light where is the problem. Many thanks. ./check: temp: not found The directory related to SEP instance 4 does not exist. The script is as follows. SEP_APP="/scp/sepx/app... (2 Replies)
Discussion started by: Sudhakar333
2 Replies

10. Shell Programming and Scripting

store awk results in a variable

I try to get the month (of last save) and the filename into a variable, is this possible ? something like this : for month in `ls -la | awk '{print $6}'` do if ] then a=filename of the matching file cp $a /Sep fi thanks, Steffen (1 Reply)
Discussion started by: forever_49ers
1 Replies
Login or Register to Ask a Question