# How do I do \<insert thing here\> in bash?

**URL:** <https://ask.cyberinfrastructure.org/t/how-do-i-do-insert-thing-here-in-bash/744>\
**Category:** Q&A\
**Tags:** hpc-getting-started, bash, researcher\
**Created:** [January 11, 2019, 7:11pm UTC](https://ask.cyberinfrastructure.org/t/how-do-i-do-insert-thing-here-in-bash/744 "2019-01-11T19:11:49Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mhanby](https://ask.cyberinfrastructure.org/user_avatar/ask.cyberinfrastructure.org/mhanby/32/50_2.png) [@mhanby](https://ask.cyberinfrastructure.org/u/mhanby)\
**Post date:** [June 3, 2020, 4:00pm UTC](https://ask.cyberinfrastructure.org/t/how-do-i-do-insert-thing-here-in-bash/744/4 "2020-06-03T16:00:09Z")

</div>

Here’s another one that came from [nixCraft](https://www.facebook.com/nixcraft/) that I use all the time. Add this to your `~/.bashrc` file to create a simple to use calculator:

```auto
calc() { echo "scale=2; $*" | bc -l; }
calc_full() { echo "$*" | bc -l; }

```

These lines create 2 functions:

- `calc`: Results are trimmed to 2 decimal places
- `calc_full`: Results are not trimmed

The usage is simple:

```auto
$ calc "1024*8" # Convert KB into MB
8192

$ calc "40*1.8+32" # Convert Celcius to Fahrenheit
104.0

$ calc "(2+2)*(2-2)" # You can also control the order of operation with ( )
0

```

---

_[View the full topic](https://ask.cyberinfrastructure.org/t/how-do-i-do-insert-thing-here-in-bash/744)._
