# bc throwing coredump

**URL:** <https://community.unix.com/t/bc-throwing-coredump/258170>\
**Category:** Shell Programming and Scripting\
**Created:** [January 25, 2010, 5:46am UTC](https://community.unix.com/t/bc-throwing-coredump/258170 "2010-01-25T05:46:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kinny](https://community.unix.com/letter_avatar/kinny/32/5_5575768a8748004e209b776fc1b2916d.png) [@kinny](https://community.unix.com/u/kinny)\
**Post date:** [January 25, 2010, 5:46am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/1 "2010-01-25T05:46:12Z")

</div>

Hi Gurus,  
I tried bc 1000 % 10 on tcsh and ksh and its throwing a core dump on a sun solaris machine.  
uname -a  
SunOS azote 5.9 Generic\_118558-39 sun4u sparc SUNW,Ultra-4  
Please let me know if you find anything.

Thanks,  
Kinny

---

<div class="post-metadata">

**Author:** ![ahmad.diab](https://community.unix.com/user_avatar/community.unix.com/ahmad.diab/32/940_2.png) [@ahmad.diab](https://community.unix.com/u/ahmad.diab)\
**Post date:** [January 25, 2010, 5:51am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/2 "2010-01-25T05:51:15Z")

</div>

using bash shell:-

```nohighlight
X=$(echo "1000%10" | bc)
echo $X

```

---

<div class="post-metadata">

**Author:** ![methyl](https://community.unix.com/letter_avatar/methyl/32/5_5575768a8748004e209b776fc1b2916d.png) [@methyl](https://community.unix.com/u/methyl)\
**Post date:** [January 25, 2010, 6:02am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/3 "2010-01-25T06:02:00Z")

</div>

What calculation are you trying to do?

---

<div class="post-metadata">

**Author:** ![kinny](https://community.unix.com/letter_avatar/kinny/32/5_5575768a8748004e209b776fc1b2916d.png) [@kinny](https://community.unix.com/u/kinny)\
**Post date:** [January 25, 2010, 6:08am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/4 "2010-01-25T06:08:22Z")

</div>

It says Illegal variable name.

Even echo "1000%10" | bc gives me a core dump.  
Please advise

---------- Post updated at 06:08 AM ---------- Previous update was at 06:07 AM ----------

I am just trying to get the reminder of 1000 divided by a user passed variable

---

<div class="post-metadata">

**Author:** ![methyl](https://community.unix.com/letter_avatar/methyl/32/5_5575768a8748004e209b776fc1b2916d.png) [@methyl](https://community.unix.com/u/methyl)\
**Post date:** [January 25, 2010, 6:29am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/5 "2010-01-25T06:29:51Z")

</div>

This would suggest that your copy of "bc" is corrupt or from a different system.

```nohighlight
Just for diagnostics.

Find out which program failed.
file core

Check whether you are actually running /usr/bin/bc
type bc

Try /usr/bin/bs to eliminate whether /usr/bin/bc is the only problem
echo "100%9"|bs
1

```

---

<div class="post-metadata">

**Author:** ![ahmad.diab](https://community.unix.com/user_avatar/community.unix.com/ahmad.diab/32/940_2.png) [@ahmad.diab](https://community.unix.com/u/ahmad.diab)\
**Post date:** [January 25, 2010, 7:02am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/6 "2010-01-25T07:02:43Z")

</div>

> [@kinny](#):
>
> It says Illegal variable name.
> 
> Even echo "1000%10" | bc gives me a core dump.  
> Please advise
> 
> ---------- Post updated at 06:08 AM ---------- Previous update was at 06:07 AM ----------
> 
> I am just trying to get the reminder of 1000 divided by a user passed variable

I had said in my post that you have to have a bash shell to do my code above

try writing the below:-

```plaintext
bash
X=$(echo "1000%10" | bc)
echo $X

```

---

<div class="post-metadata">

**Author:** ![kinny](https://community.unix.com/letter_avatar/kinny/32/5_5575768a8748004e209b776fc1b2916d.png) [@kinny](https://community.unix.com/u/kinny)\
**Post date:** [January 25, 2010, 8:39am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/7 "2010-01-25T08:39:53Z")

</div>

Hi Ahmad,  
I tried this with bash and I get no output.

```nohighlight
bash-2.00$ X=$(echo "1000%9" | bc);echo $X

bash-2.00$ X=$(echo "1000%10" | bc);echo $X

bash-2.00$

```

---------- Post updated at 08:39 AM ---------- Previous update was at 08:36 AM ----------

```nohighlight
bash-2.00$ bc
1000%3
Abort (core dumped)
bash-2.00$

```

---

<div class="post-metadata">

**Author:** ![pludi](https://community.unix.com/user_avatar/community.unix.com/pludi/32/1278_2.png) [@pludi](https://community.unix.com/u/pludi)\
**Post date:** [January 25, 2010, 8:59am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/8 "2010-01-25T08:59:13Z")

</div>

Can you please post the output of these 2 commands:

```nohighlight
$ file ` which bc`
$ ldd -r `which bc`

```

---

<div class="post-metadata">

**Author:** ![methyl](https://community.unix.com/letter_avatar/methyl/32/5_5575768a8748004e209b776fc1b2916d.png) [@methyl](https://community.unix.com/u/methyl)\
**Post date:** [January 25, 2010, 9:44am UTC](https://community.unix.com/t/bc-throwing-coredump/258170/9 "2010-01-25T09:44:19Z")

</div>

And the same for "dc" (the program which "bc" calls).

Do other programs in the SUNWesu package work?  
e.g. cal , sum
