LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-22-2021, 05:29 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
Linux BC calculator multiple variables must be read or seen by Bash


How can linux BC calculator multiple variables, not just one obtain by command substitution, be recognized or seen by Bash
 
Old 09-22-2021, 05:52 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,674

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
Quote:
Originally Posted by BudiKusasi View Post
How can linux BC calculator multiple variables, not just one obtain by command substitution, be recognized or seen by Bash
My thought is that your first language may not be english. Can you explain in more detail what exactly you mean?
 
Old 09-22-2021, 05:57 PM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
A little more info would be nice.

What are you doing that needs bc?
How many variables are you talking about?
What is to be done with the variables content?
Why cannot everything be done within a script that uses the variables?

Your incomplete info makes an answer impossible.

There are only 2 ways to use variable values. They either must be used within their scope within a script/program or they must be saved to a file that can be read by another program/script.
 
Old 09-22-2021, 06:00 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,740

Rep: Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923Reputation: 5923
I'm not exactly sure what the OP is asking either but will take a guess...

Code:
#!/bin/bash
x=2
y=3

result=$(echo "$x*$y" | bc)
echo "$x * $y = $result"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Calculator N+ is an open source scientific calculator for your smartphone LXer Syndicated Linux News 0 11-27-2019 06:21 AM
Bash to find all placeholder variables in a file and replace will real variables spadez Programming 6 11-26-2013 12:24 PM
[SOLVED] Bash script to read multiple variables from a list then output to command diplo707 Programming 6 04-23-2012 12:46 PM
i hope linux geeks must have seen this by now...^_^ dEnDrOn General 8 01-05-2012 06:56 AM
Bash Script: parse active process stderr, strip, dump into variables, use variables TimeFade Programming 1 02-13-2010 06:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration