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
1
vote
0 answers

Using expr to extract an IP from a URL

On, Mac OS X I'm trying to use expr to extract an IP address from a URL string. expr tcp://192.168.59.103:2376 : '^\([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\)' This returns an empty string.
MoxieandMore
  • 1,096
  • 11
  • 8
0
votes
1 answer

Track the historical change of Status

I defined the folloing Expr Formula: history.changes.Filter($.field="status").changeGroup.map(CONCAT($.author.user_display_name(), " set on ", FORMAT_DATETIME($.timestamp, ""yyy-MM-dd HH:mm:ss"))) to figure out who, when has changed the Status.…
And_R
  • 1,647
  • 3
  • 18
  • 32
0
votes
1 answer

How to multiply decimals using expr

When I run the following command: expr 1.2 * 13 I get this error: expr: syntax error: unexpected argument '12' I expect I am missing a syntax. What is it?
Allan Xu
  • 7,998
  • 11
  • 51
  • 122
0
votes
0 answers

I am getting expr syntax errors for a simple equations

here is the code: lidarachynska@MacBook-Air-Lida ~ % cd rachynska lidarachynska@MacBook-Air-Lida rachynska % vim bin/com2 lidarachynska@MacBook-Air-Lida rachynska % chmod a+x bin/com2 lidarachynska@MacBook-Air-Lida rachynska %…
Korostev
  • 3
  • 2
0
votes
1 answer

How to multiply series of numbers using expr in bash

I was trying to get the factorial of a number in bash,it's an easy program obviously ,using loop I can do this,for example #!/usr/bin/bash echo "Enter number" read number #echo `seq -s "*" 1 $number | bc` result=1 for((i=1;i<=number;i++)) …
0
votes
1 answer

Double variable substitution in tcl

I am getting an error invalid character "." while running following code in tcl shell : set var "p.txt_bc" set p.txt_bc 1 expr $$var invalid character "." in expression "$p.txt_bc" How to handle the "." character here so that the output is 1 ? I…
0
votes
1 answer

Matching a regex containing variable environment in RewriteCond of .htaccess

The goal here is if the URL has got a trailing slash, like h2tps://domain.com/page/, redirect to h2tps://domain.com/page h2tp(s)://(www.)domaine.com/page/ => h2tps://domain.com/page It should work only in prod environment, not dev, it's why the…
Cyril
  • 177
  • 1
  • 7
0
votes
1 answer

pyspark add int column to a fixed date

I have a fixed date "2000/01/01" and a dataframe: data1 = [{'index':1,'offset':50}] data_p = sc.parallelize(data1) df = spark.createDataFrame(data_p) I want to create a new column by adding the offset column to this fixed date I tried different…
NewPy
  • 623
  • 1
  • 5
  • 14
0
votes
1 answer

How to filter field in array in MongoDB

I have array: {'_id': ObjectId('7262718c217dda3ad90ef151'), 'SomeText': "aaa", 'items': [{'status': 500, 'x': 1, 'y': None, 'price': 3}, { 'status': 500, 'x': 2, 'y': None, 'price': 4}]} {'_id': ObjectId('7262718c217dda3ad90ef152'), 'SomeText':…
0
votes
0 answers

exp attribute in replicate function in R is not working

I want to replicate an expression using the replicate function in R. The expression is a multiplication containing lnorm distribution. The expression gives different results outside the replication function but when I insert it as an attribute into…
MariaK
  • 1
  • 1
0
votes
1 answer

Why do I get a syntax error when using expr in bash(MacOS)?

I'm just starting to learn shell, and I felt really puzzled when I got a syntax error in this simple code : str="Hello world!" echo $(expr length "$str") But this code can work on Ubantu actually. Is it because my bash version is outdated? Or is it…
0
votes
3 answers

I need to insert the output of the count, incremented from a loop 'for' within a varyable 'list' in TCL

I want to list the increments in "$ i" of the loop for variable in '[list ]' mode. For then, I could calculate the values with '[expr ]'. I will leave here a didactic example, to simplify the idea. To look: set i 1 while {$i <= 9} { global value …
Diego Henrique
  • 255
  • 1
  • 16
0
votes
1 answer

Gurobi QuadExpr : what should I change to y.value

for i in P: S=(y[i]-R*p[i])*(y[i]-R*p[i])/(p[i]*p[i]) print(S) When I run the above program, the output is as below. How should I change it? I want to output y (i) to calculate the value.
0
votes
1 answer

Using variable in expression with Nullif fails

I'm using the code below to convert an empty string to Null. I don't get an error but it remains an empty string. I suspect an incorrect use of the variable col_name in expr for col_name in ['col1', 'col2']: df_new = df \ …
John Doe
  • 9,843
  • 13
  • 42
  • 73
0
votes
1 answer

How to compute exponentiation and roots in the shell?

I'm a beginner in shell and linux in general, it's a Shell Arithmetic question and I can't figure out what to write in terminal to solve these three equations. I'm sorry if it seems a bad question, I tried echo command and expr, but all of them are…
James1970
  • 11
  • 1