{"id":1912,"date":"2022-03-04T22:12:24","date_gmt":"2022-03-04T16:42:24","guid":{"rendered":"https:\/\/smarttech101.com\/?p=1912"},"modified":"2023-03-25T00:52:09","modified_gmt":"2023-03-24T19:22:09","slug":"bc-command-in-linux","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/bc-command-in-linux\/","title":{"rendered":"bc command in Linux"},"content":{"rendered":"\n<p>bc command in Linux is actually a calculator &#8220;language&#8221;. It comes preinstalled with Linux. Like bash and zsh, you can use it in interactive mode (i.e. type bc in your terminal, hit Enter button, put your equations and get your answers) as well as in shell scripts.<\/p>\n\n\n\n<p>Some people like to call it the &#8220;<strong>Basic Calculator<\/strong>&#8221; and discard it altogether. But I call it the &#8220;<strong>Best Calculator&#8221;<\/strong> because it provides advanced facilities as well &#8211; It has <code>for<\/code> and <code>while<\/code> loops, and if-else statements, among others with syntax similar to the C programming language.<\/p>\n\n\n\n<p>Here, in this article, I will touch upon its basic applications and how I use it in the shell scripts and in its interactive mode.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table of contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#why_bc_is_the_best_calculator_in_linux\">Why bc is the best calculator in Linux<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_use_bc_command_interactively\">How to use bc command interactively<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_set_the_scale_outputs_in_decimal_point_in_bc\">How to set the scale (outputs in decimal point) in bc<\/a><\/li>\n\n\n\n<li><a href=\"#variables_and_values_in_bc\">Variables and values in bc<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#previous_answer_in_bc_using_the_last_variable\">Previous answer in bc using the &#8220;last&#8221; variable<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a href=\"#how_to_remove_the_warranty_and_other_information_from_the_bc_command_in_linux\">How to remove the warranty and other information from the bc command in Linux<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_use_the_bc_command_in_linux_to_convert_a_number_from_one_base_to_another\">How to use the bc command in Linux to convert a number from one base to another<\/a><\/li>\n\n\n\n<li><a href=\"#trigonometric_logarithmic_and_exponential_functions_in_bc_command_in_linux\">Trigonometric, logarithmic, and exponential functions in bc command in Linux<\/a><\/li>\n\n\n\n<li><a href=\"#advanced_bc_commands_in_linux\">Advanced bc commands in Linux<\/a><\/li>\n\n\n\n<li><a href=\"#executing_bc_command_on_a_file_containing_all_the_equations\">Executing bc command on a file containing all the equations<\/a><\/li>\n\n\n\n<li><a href=\"#how_to_use_bc_command_in_shell_scripts\">How to use bc command in shell scripts<\/a><\/li>\n\n\n\n<li><a href=\"#creating_bc_alias_to_set_the_scale_and_remove_the_warranty_information\">Creating bc alias to set the scale and remove the warranty information<\/a><\/li>\n\n\n\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"why_bc_is_the_best_calculator_in_linux\">Why bc is the best calculator in Linux<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Many of you prefer &#8220;modern&#8221; Graphical User Interface (GUI) based calculators to bc &#8211; One of the reasons is its default &#8220;ugly&#8221; look. Another reason is that every time you enter into bc, you need to set a scale for total number of decimal digits printed after the decimal point. But, for me, they are not the problems. You can very easily <strong>set an alias for both removing the warranty warnings as well as setting the scale<\/strong>. I will talk about this in the upcoming paras.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"594\" height=\"727\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/image.png?resize=594%2C727&#038;ssl=1\" alt=\"Figure: &quot;ugly&quot; bc \" class=\"wp-image-1915\"\/><figcaption class=\"wp-element-caption\">Figure: &#8220;ugly&#8221; bc <\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Another feature of the bc is its usage of space &#8211; less RAM, less Hard Disk, less screen space given lack of buttons etc.<\/li>\n\n\n\n<li>At the same time for the calculation history &#8211; you don&#8217;t have to scroll much.<\/li>\n\n\n\n<li>All the terminal&#8217;s shortcut keys are available &#8211; scroll up\/down, copy and paste, etc. Similarly, if you use vim keys in your terminal (for example I use <a href=\"https:\/\/smarttech101.com\/urxvt-installation-color-scheme-fonts-resize-etc\/#keyboard-select-moving-around-using-keyboard-instead-of-mouse\" target=\"_blank\" rel=\"noreferrer noopener\">vim keys in my URxvt<\/a>, and alacritty), that will be available as well.<\/li>\n\n\n\n<li>Terminal themes &#8211; colorscheme, pywal, etc. &#8211; are automatically get available. <\/li>\n\n\n\n<li>It even supports comparision and boolean operators, functions such as <code>read<\/code> similar to that in the C language. So you can exploit your talent in that regard as well and do complex calculations.<\/li>\n\n\n\n<li>You can enhance its features by writing your own functions such as differentiation and integration functions, factorial(x), etc. in files and load them at the start of the bc. It is described below in one of the headings.<\/li>\n\n\n\n<li>Quiet Versatile &#8211; you can use it not only interactively but also in scripts which the GUI based calculator can&#8217;t.<br><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"307\" height=\"30\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/image-1.png?resize=307%2C30&#038;ssl=1\" alt=\"Fig: the above i3bar uses paste -sd '+' &quot;$rxdeltafile&quot; | bc\" class=\"wp-image-1916\"\/><figcaption class=\"wp-element-caption\">Fig: the above i3bar uses <code>paste -sd '+' \"$rxdeltafile\" | bc<\/code><\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In <code>bash<\/code> or <code>zsh<\/code>, you can use their Arithmatic Evaluation functionality i.e. <code>((expression))<\/code>. But in strictly POSIX compliant shells such as <code>dash<\/code>, there is nothing like <code>((expression))<\/code> and hence, you don&#8217;t have any option other than the <code>bc<\/code>. <\/li>\n\n\n\n<li>On top of that, bash shell does not even provide floating point calculations (ex &#8211; <code>echo $((5+5.1))<\/code> throws error in bash) . So in this case, bc is a life saver.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_use_bc_command_interactively\">How to use bc command interactively<\/h2>\n\n\n\n<p>To enter into bc&#8217;s interactive mode, simply use the command bc in your terminal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc\nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nThis is free software with ABSOLUTELY NO WARRANTY.\nFor details type `warranty'.<\/code><\/pre>\n\n\n\n<p>You can also force the bc command into the interactive mode using the flag <code>-i<\/code> or <code>--interactive<\/code>.<\/p>\n\n\n\n<p><strong>Quit: <\/strong>To quit from the bc&#8217;s interactive mode, use the command <code>quit<\/code>, or shortcut key <code>ctrl + \\<\/code> (the SIGQUIT), or <code>ctrl + c<\/code> (the SIGINT) or <code>ctrl + d<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_set_the_scale_outputs_in_decimal_point_in_bc\">How to set the scale (outputs in decimal point) in bc<\/h2>\n\n\n\n<p>By default, bc sets the scale to 0. That means &#8211; zero number of digits will be printed out after the decimal point. In other words, only the integer part is printed. To set it to some non-zero value use <code>scale=n<\/code> as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc\nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nThis is free software with ABSOLUTELY NO WARRANTY.\nFor details type `warranty'. \nscale=3\n5\/4\n1.250<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"variables_and_values_in_bc\">Variables and values in bc<\/h2>\n\n\n\n<p>This is one of the features not available in GUI-based calculators. You can assign any value to any variable. <\/p>\n\n\n\n<p>For the following example, I am assigning value <code>3<\/code> to a variable <code>var<\/code>. Now, you can use this value in the future!!! Then the <code>print<\/code> command prints any variable&#8217;s value. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc\nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nThis is free software with ABSOLUTELY NO WARRANTY.\nFor details type `warranty'.\nvar=3\nvar1=var*2\nprint var1\n6<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"previous_answer_in_bc_using_the_last_variable\">Previous answer in bc using the &#8220;last&#8221; variable<\/h3>\n\n\n\n<p>The <code>last<\/code> variable is a predefined variable and it contains the last answer. Using this, you can concatenate your answers and solve a long equation. Without the <code>last<\/code> variable, you will need to constantly copy and paste the answers. For example, to solve 3+8789\/3*6*9 step by step:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc\nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nThis is free software with ABSOLUTELY NO WARRANTY.\nFor details type `warranty'.\nscale=10\n8789\/3\n2929.6666666666\nlast*6\n17577.9999999996\nlast*9\n158201.9999999964\n3+last\n158204.9999999964<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_remove_the_warranty_and_other_information_from_the_bc_command_in_linux\">How to remove the warranty and other information from the bc command in Linux<\/h2>\n\n\n\n<p>To remove all kinds of information from bc, you need to use the <code>--quiet<\/code> or <code>-q<\/code> flag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc --quiet\nscale=3\n5\/4\n1.250<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_use_the_bc_command_in_linux_to_convert_a_number_from_one_base_to_another\">How to use the bc command in Linux to convert a number from one base to another<\/h2>\n\n\n\n<p>bc command has <code>ibase<\/code> and <code>obase<\/code> variables for input and output bases respectively.<\/p>\n\n\n\n<p>For example, to find the decimal number corresponding to hexadecimal number &#8216;E&#8217;, you need to define obase as 10 and ibase as 16.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc --quiet\nobase=10\nibase=16\nE\n14<\/code><\/pre>\n\n\n\n<p>\u26a0\ufe0f <strong>Be Careful<\/strong>: if you set ibase first and then obase, you will get unexpected answers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc --quiet\nibase=16\nobase=10\nE\nE<\/code><\/pre>\n\n\n\n<p>The reason is that the first line&#8217;s ibase=16 asks the bc to treat all the upcoming numbers as hexadecimal numbers. Therefore, the 10 in the next line <code>obase=10<\/code> becomes 16. Hence, the second line gets transformed into <code>obase=16<\/code>. And that&#8217;s why E is printed as E.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"trigonometric_logarithmic_and_exponential_functions_in_bc_command_in_linux\">Trigonometric, logarithmic, and exponential functions in bc command in Linux<\/h2>\n\n\n\n<p>To use these functions, you need to load the math library using the flag <code>--mathlib<\/code> or <code>-l<\/code>. Here is a list of available functions in the math library and their descriptions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>s(x) is sine(x) where x is in radians; similarly, c(x) is cosine(x).<\/li>\n\n\n\n<li>a(y) is tan<sup>-1<\/sup>(y) and the answer will be in radians.<\/li>\n\n\n\n<li>l(x) is log<sub>e<\/sub>(x) i.e. ln(x).<\/li>\n\n\n\n<li>e(x) is e<sup>x<\/sup>.<\/li>\n\n\n\n<li>Bessel function j(n,x)<\/li>\n<\/ul>\n\n\n\n<p>At the same time, it also sets the default scale to 20 as you can in the following example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc --quiet --mathlib\npi=4*a(1)\ns(pi)\n.00000000000000000002<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"advanced_bc_commands_in_linux\">Advanced bc commands in Linux<\/h2>\n\n\n\n<p>Similar to C language, bc has its own conditional statements (<code>if-else<\/code>), loops (<code>for<\/code> and <code>while<\/code>), <code>break<\/code> and <code>continue<\/code>, <code>return<\/code>, comparison operators (<code>&gt;=, &lt;=, &lt;, &gt;, ==, !=<\/code>), boolean operators (<code>!, ||, &amp;&amp;<\/code>), <code>++var, var++, --var, var--<\/code>, <code>read<\/code>, <code>return<\/code> and other functions.<\/p>\n\n\n\n<p>Please look at the man page to know more.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"executing_bc_command_on_a_file_containing_all_the_equations\">Executing bc command on a file containing all the equations<\/h2>\n\n\n\n<p>You can put all the commands, which you are going to type in the interactive mode, into a file and then execute the bc command on that file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc FILE<\/code><\/pre>\n\n\n\n<p>Now, the bc will first execute all lines one by one starting from the beginning in the FILE. After executing these lines, bc will read from the standard input. If there is no standard input, bc will enter into the interactive mode.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ cat equation.txt\nprint \"remainder of 5\/4 is \"\n5%4\n\/* this is a comment *\/\nlast+2\n\n&#91;ajay@lenovo ~]$ bc equation.txt \nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nThis is free software with ABSOLUTELY NO WARRANTY.\nFor details type `warranty'. \nremainder of 5\/4 is 1\n3\n^C\n(interrupt) Exiting bc.\n\n&#91;ajay@lenovo ~]$ echo 'print \"standard input\\n\"' | bc equation.txt\nremainder of 5\/4 is 1\n3\nstandard input\n\n&#91;ajay@lenovo ~]$<\/code><\/pre>\n\n\n\n<p>\ud83d\udcdd <strong>Note 1:<\/strong> As you can see in the above example, <code>\/* *\/<\/code> is used for comment, and <code>%<\/code> is used for the remainder.<\/p>\n\n\n\n<p>\ud83d\udcdd <strong>Note 2:<\/strong> <code>^C<\/code> is ctrl+c I pressed to exit from the interactive mode.<\/p>\n\n\n\n<p>\ud83d\udcdd <strong>Note 3: <\/strong>You can also use multiple files containing your bc-commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc FILE1 FILE2<\/code><\/pre>\n\n\n\n<p>\ud83d\udcdd <strong>Note 4: <\/strong>Use the command <code>quit<\/code> at the end of the <code>FILE<\/code> to prevent bc from entering into the interactive mode.<\/p>\n\n\n\n<p>\ud83d\udc68\u200d\ud83d\udd27 <strong>Application: <\/strong>Some of you complain that the GUI-based calculators have extra facilities which are not available in bc like unit and currency conversions. <strong>In bc, you can easily add new functionalities<\/strong> by loading FILE(s) at the start. For example, to create a factorial function (<code>n!<\/code>), create a file <code>factorial.bc<\/code> with the following contents in it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define f (x) {\n                if (x &lt;= 1) return (1);\n                return (f(x-1) * x);\n              }<\/code><\/pre>\n\n\n\n<p>Now, <code>5!<\/code> gives <code>5*4*3*2*1=120<\/code> as given below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ bc --quiet factorial.bc \nf(5)\n120<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_use_bc_command_in_shell_scripts\">How to use bc command in shell scripts<\/h2>\n\n\n\n<p>In order to use bc in shell scripts, just pipe all the commands, which you would have typed in its interactive mode, into the bc.<\/p>\n\n\n\n<p>Learn here about\u00a0<a href=\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\" target=\"_blank\" rel=\"noreferrer noopener\">what is a shell script and how to create one.<\/a><\/p>\n\n\n\n<p>For instance, using the <a href=\"https:\/\/smarttech101.com\/echo-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\">echo command<\/a>, I will be executing the following command:-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@lenovo ~]$ echo 'scale=3; 5\/4' | bc\n1.250<\/code><\/pre>\n\n\n\n<p><strong>Fun Point \ud83d\ude03<\/strong>: The above behavior is just like that in <a href=\"https:\/\/smarttech101.com\/bluetoothctl-management-of-bluetooth-devices-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">bluetoothctl<\/a> &#8211; you can either put your Bluetooth commands directly into the interactive-bluetoothctl or pipe them into the bluetoothctl using echo. This is what I love about Linux. There are many features that are the same across a wide variety of tools and commands.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating_bc_alias_to_set_the_scale_and_remove_the_warranty_information\">Creating bc alias to set the scale and remove the warranty information<\/h2>\n\n\n\n<p>Put the following alias in your shell configuration file (<code>.bashrc<\/code> and <code>.zshrc<\/code> for bash and zsh respectively):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>alias bc='bc --quiet &lt;(echo \"scale=5;print\\\"scale=5\\n\\\"\")'<\/code><\/pre>\n\n\n\n<p>\ud83d\udcd6 <strong>Explanation: <\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The above alias prints <code>\"scale=5\"<\/code> into the bc&#8217;s interactive mode just to remind you that scale=5 has been set and you don&#8217;t have to set it again.<\/li>\n\n\n\n<li><code>&lt;(command)<\/code> in bash or zsh is called <strong>Process Substitution<\/strong>. It is used to simulate a file. The <code>command<\/code>&#8216;s output becomes the content of the file.<\/li>\n<\/ul>\n\n\n\n<p>Now, the command <code>bc<\/code> will start with no information and it will set the scale automatically for you. Similarly, you can also put other bc commands in the alias.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"560\" height=\"441\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/image-2.png?resize=560%2C441&#038;ssl=1\" alt=\"Fig: bc command in Linux before setting the alias\" class=\"wp-image-1917\"\/><figcaption class=\"wp-element-caption\">Fig: bc command in Linux before setting the alias<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"551\" height=\"500\" src=\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/image-3.png?resize=551%2C500&#038;ssl=1\" alt=\"Fig: bc command in Linux after setting the alias\" class=\"wp-image-1918\"\/><figcaption class=\"wp-element-caption\">Fig: bc command in Linux after setting the alias<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>That was just the tip of the iceberg. For me, it is the <strong>Best Calculator instead of the Basic Calculator.<\/strong> What is it for you or did you just dismiss it out of the hand due to paucity of time &#8211; write it in the comment section.<\/p>\n\n\n\n<p>Thanks for reading. If you have any suggestions\/problems, please put a comment for them as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>learn bc command in Linux, set scale, remove warranty info, set an alias for these two, use sin, cos, tan, log, etc, use bc in shell scripts<\/p>\n","protected":false},"author":2,"featured_media":1938,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[17],"tags":[18,35],"class_list":["post-1912","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line-tools","tag-command-line-tools","tag-core-linux-utilities"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>bc command in Linux | SmartTech101<\/title>\n<meta name=\"description\" content=\"learn bc command in Linux, set scale, remove warranty info, set an alias for these two, use sin, cos, tan, log, etc, use bc in shell scripts\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/bc-command-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"bc command in Linux | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"learn bc command in Linux, set scale, remove warranty info, set an alias for these two, use sin, cos, tan, log, etc, use bc in shell scripts\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/bc-command-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-04T16:42:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-24T19:22:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"bc command in Linux\",\"datePublished\":\"2022-03-04T16:42:24+00:00\",\"dateModified\":\"2023-03-24T19:22:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/\"},\"wordCount\":1582,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1\",\"keywords\":[\"Command Line Tools\",\"core linux utilities\"],\"articleSection\":[\"Command Line Tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/bc-command-in-linux\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/\",\"url\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/\",\"name\":\"bc command in Linux | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1\",\"datePublished\":\"2022-03-04T16:42:24+00:00\",\"dateModified\":\"2023-03-24T19:22:09+00:00\",\"description\":\"learn bc command in Linux, set scale, remove warranty info, set an alias for these two, use sin, cos, tan, log, etc, use bc in shell scripts\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/bc-command-in-linux\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1\",\"width\":1280,\"height\":720,\"caption\":\"bc command in Linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/bc-command-in-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"bc command in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"bc command in Linux | SmartTech101","description":"learn bc command in Linux, set scale, remove warranty info, set an alias for these two, use sin, cos, tan, log, etc, use bc in shell scripts","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smarttech101.com\/bc-command-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"bc command in Linux | SmartTech101","og_description":"learn bc command in Linux, set scale, remove warranty info, set an alias for these two, use sin, cos, tan, log, etc, use bc in shell scripts","og_url":"https:\/\/smarttech101.com\/bc-command-in-linux\/","og_site_name":"SmartTech101","article_published_time":"2022-03-04T16:42:24+00:00","article_modified_time":"2023-03-24T19:22:09+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png","type":"image\/png"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"bc command in Linux","datePublished":"2022-03-04T16:42:24+00:00","dateModified":"2023-03-24T19:22:09+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/"},"wordCount":1582,"commentCount":0,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1","keywords":["Command Line Tools","core linux utilities"],"articleSection":["Command Line Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/bc-command-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/","url":"https:\/\/smarttech101.com\/bc-command-in-linux\/","name":"bc command in Linux | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1","datePublished":"2022-03-04T16:42:24+00:00","dateModified":"2023-03-24T19:22:09+00:00","description":"learn bc command in Linux, set scale, remove warranty info, set an alias for these two, use sin, cos, tan, log, etc, use bc in shell scripts","breadcrumb":{"@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/bc-command-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1","width":1280,"height":720,"caption":"bc command in Linux"},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/bc-command-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"bc command in Linux"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/03\/thumbnail.png?fit=1280%2C720&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1912"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=1912"}],"version-history":[{"count":5,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1912\/revisions"}],"predecessor-version":[{"id":2672,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/1912\/revisions\/2672"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/1938"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=1912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=1912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=1912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}