Questions tagged [expr]

Command-line expression evaluator

The expr utility evaluates expressions and writes the result on standard output.

See the FreeBSD Man page.

102 questions
0
votes
1 answer

Why do I get this result with SymPy's parse_expr

I wrote the following code: simplification = parse_expr(str_expression, evaluate=True) expression = parse_expr(str_expression, evaluate=False) if expression == simplification: msg = "Couldn't simplify!" else: msg = "Simplified:" I thought…
Phil
  • 23
  • 6
0
votes
1 answer

Why are double quotes needed in defining this variable in shell scripting?

Consider this piece of code: #!/bin/bash +x echo -n "String: " read s n=`expr index $s " "` if [ $n -gt 0 ]; then m=`expr $n - 1` echo "Nome: " `expr substr $s 1 $m` fi When I run it with the and write "John Smith" in the prompt, I…
Daniel Oscar
  • 287
  • 1
  • 9
0
votes
1 answer

How to match this regexp in UNIX with expr?

Can some body pl tell me why this if condition doesn't output Matched and how to change the reg exp pattern with expr to display the output as Matched. The thing is that instead of BH in the var variable there can be any country code like US or CA.…
Gautam S
  • 41
  • 1
  • 1
  • 7
0
votes
1 answer

Arithmetic in web scraping in a shell

so, I have the example code here: #!/bin/bash clear curl -s https://www.cnbcindonesia.com/market-data/currencies/IDR=/USD-IDR | html2text | sed -n '/USD\/IDR/,$p' | sed -n '/Last updated/q;p' | tail -n-1 | head -c+6 && printf "\n" exit 0 this…
CuriousNewbie
  • 319
  • 4
  • 13
0
votes
1 answer

Error associated with "EXPR must be a length 1 vector" when extracting fixed effect coefficients

I am running a random effects mediation analysis using lme4::lmer and the model converged. However, when using FEmatrix <- coef(medmodelsummary) to extract the fixed effects, I got the following error message: Error in switch(chain, 1 = -10, 2 =…
0
votes
1 answer

expr command in tcl 8.4.9 version treats result as 32 bit signed integer only

I am running Tcl 8.4.9. I'm dealing with 64-bit address and need to perform some arithmetic operations on 64-bit address. I used the expr command but it returns a negative result. I do not want to upgrade Tcl version is there any other alternative…
0
votes
1 answer

bash script expr - arithmetic syntax error

I have made a bash script to monitor my network traffic every 10 sec using ifconfig. It must be ifconfig else I would have used a different tool. My issue is because my counter is so high number I have to use expr to do the calculation, however expr…
Svan
  • 41
  • 6
0
votes
1 answer

Checking for greater value from JSON

I need some advice.. i am writing a BASH script, to check for information in a JSON file. But i need check for value which are greater than a number entered into by the user. So if the user enters in 5.6, (has to be decimal), then i will check for…
Junes786
  • 13
  • 7
0
votes
2 answers

Can i use !="" to say "not empty"?

Because bash returns me that != is invalid, but it's a basic operator. I try to use it in a three expression for loop for (( c=1; ${!c}!=""; c++ )) do
wxi
  • 7
  • 4
0
votes
0 answers

odoo v12 xpath new field not visible

i have a issue with odoo v12. manifest file 'depends': ['stock','product'], # always loaded 'data': [ 'views/stock_production_lot_views.xml', # 'security/ir.model.access.csv', ], The module class class ProductionLot(models.Model): …
Sean S
  • 3
  • 5
0
votes
1 answer

Meaning of word=$word"`expr substr '${ -b :board}' 1 3`"?

I am working on some bash scripting conversion to C++ and came across this line... word="yahoo" word=$word"`expr substr '${ -b :board}' 1 3`" I understand what expr substr does, but the argument that I provide "${ -b :board}" does not make any…
0
votes
1 answer

Trying to understand how eval(expr, envir = df) works

I have built a function which seems to work, but I don't understand why. My initial problem was to take a data.frame which contains counts of a population and expand it to re-create the original population. This is easy enough if you know the…
Tom Greenwood
  • 1,502
  • 14
  • 17
0
votes
1 answer

floating point operations in Linux using expr utility

Not sure, but I'm unable to get this. 38/1024 = 0.0371 When i'm performing: echo "scale=2; 15 / 0.0371" |bc, it gives me result: 404.31 But, when i', performing : echo 'scale=2; 15/(38/1024)' |bc , the output is: 500.00 Why there's difference in…
User123
  • 1,498
  • 2
  • 12
  • 26
0
votes
2 answers

Bash Math Oddity (Floating Point Division)

So I'm having some trouble with bash / bc math here.. I'm trying to print the filesize in of a backup after I move it to my gdrive via rclone for backup. So I get the filesize via an rclone ls statement with awk print $1 which works great. In my…
ndom91
  • 719
  • 1
  • 9
  • 19
0
votes
2 answers

MongoDB unknown top level operator: $expr nodejs

I tried finding solution for this online, but no success. This is the code: Invoice.count( { $expr: {$gt: [ "$totalAmount", "$remainingDebt" ]} } ).exec(callback); where totalAmount and remainingDebt are fields in schema Invoice. The result I get…
Nebojsa
  • 133
  • 1
  • 8