assinging the printf result to variables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting assinging the printf result to variables
# 1  
Old 02-03-2012
assinging the printf result to variables

Getting the below error while executing this. Able to run the below commands Individually.
Code:
#!/bin/bash
a=$(printf "%d\n" 0x01E);
b=$(printf "%d\n" 0x01A);
echo $a
echo $b
c=`expr $a - $b`
echo $c
 
syntax error at line 2: `a=$' unexpected


Last edited by Franklin52; 02-03-2012 at 02:03 PM.. Reason: Please use code tags for data and code samples, thank you
# 2  
Old 02-03-2012
Why not this?
Code:
echo "ibase=16; 01E - 01A" | bc

--ahamed
# 3  
Old 02-03-2012
It's working... Thanks Ahamed..
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 compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

2. Programming

Passing printf formatting parameters as variables

Hi, I haven't programed in C in a few years. I have been doing a lot of shell scripting, I.E. not really programming anything heavy. :o That said, I have a script that gives hourly usage statistics for our email server. It runs w-a-y to slow as a script for my impatience, and needs to... (7 Replies)
Discussion started by: mph
7 Replies

3. Shell Programming and Scripting

Assinging output of cut command

Hi, I have the files in the following files in a folder 19996587342 19487656550 19534838736 And i need to get the first 6 characters from the abvoe files so i used the following script #!/bin/ksh for i in 19* do txt= `$i | cut -c -6` echo "$txt" done The error is at... (4 Replies)
Discussion started by: smile689
4 Replies

4. Shell Programming and Scripting

fieldwidths, printf and calculations with variables

Hello guys, I have a problem concerning the formatting when performing calculations with variables passed to awk and using fieldwidth definitions and printf. I have the following code: awk 'BEGIN{ FIELDWIDTHS = "5 3 7 5 8 8 8" }{if ($7 != "") printf"%s%-s%s%s%s%s%s\n",$1,$2,$3,$4,$5,$6,$7;... (2 Replies)
Discussion started by: origamisven
2 Replies

5. Shell Programming and Scripting

Not able to get result to unix variables

I am trying to get the Srcreccnt and Tgtreccnt from unix files and update the oracle table. But i get the below error: ERROR at line 1: ORA-00936: missing expression update velocity_process_control set SOURCE_RECORD_COUNT=,SOURCE_RECORD_COUNT= where batch_id= * ERROR at line 1:... (8 Replies)
Discussion started by: vsmeruga
8 Replies

6. Shell Programming and Scripting

using AWK printf with userdefine variables

seems simple but i've not been successfull in adding the value of a Variable to a every line of a file using AWK & printf i've come up with the following, but it's not working.:mad: --- mydatafile.dat e.g. of data in file: cau_actvty_fa_lrf.ksh fan_soco_fa.ksh ny_sum_lst.ksh... (4 Replies)
Discussion started by: danmauer
4 Replies

7. Shell Programming and Scripting

Need Help in assinging a value to a Variable !!

Hi all i am writing a shell , which will get input from the user and then try to change the CASE to lower echo "Please enter the unix server name ::" read unix1 unix 2 =tr '' '' < $unix1 echo $unix2 its not giving me the result in lower case.. User input will be in Upper case and... (2 Replies)
Discussion started by: raghav1982
2 Replies

8. UNIX for Dummies Questions & Answers

display the result of wc -l with words before and after the result

hello showrev -p | wc -l returns: 381 What to do in case I want to have this output: number of lines returned by showrev -p is: 381 thx (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

9. Shell Programming and Scripting

How printf handles empty variables

See attached file that includes code, input and output. I am processing a colon delimited input file and building a ":" (colon) delimited output file. My printf statement prints contents of each of 20 variables and puts them into a record file. I am pushing out approximately 120 records. The... (2 Replies)
Discussion started by: Skyybugg
2 Replies

10. Shell Programming and Scripting

awk printf for user defined variables

I am working on a SunFire 480 - uname -a gives: SunOS bsmdb02 5.9 Generic_112233-08 sun4u sparc SUNW,Sun-Fire-480R I am tyring to sum up the total size of all the directories for each running database using awk: #!/usr/bin/ksh for Database in `ps -efl | grep "ora_pmon" | grep -v grep |... (1 Reply)
Discussion started by: jabberwocky
1 Replies
Login or Register to Ask a Question