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

list sorting using apply function of Tcl

suppose I have a list like below: set listNums {0 -1 5 5 -5 1 10 100 -10 -10 1000} I want to sort it using the absolute values. I picked up the below from another script. I am having a tough time understanding this. Can someone help me understand…
user3512999
  • 139
  • 1
  • 8
0
votes
1 answer

How to use expr inside regsub in TCL?

Suppose, set s1 "some4number" I want to change it to some5number. I was hoping that this would work : regsub {(\d)(\S+)} $s1 "[expr \\1 + 1]\\2" But it errors out. What would be the ideal way to do this in TCL ?
Sidharth C. Nadhan
  • 2,191
  • 2
  • 17
  • 16
0
votes
1 answer

Apache 2.4 Date Expressions

Pre Apache 2.4 I could write this Show this text during the specified Date/Time I have tried several…
SteveL
  • 77
  • 9
0
votes
1 answer

Variables in expr regular expressions

I have a simple bash script. It reads a bunch of HTML from the file test.html and pulls out a substring, but right now it's not outputting anything. grep yt-lockup-content test.html | while read -r line; do datasession=`expr "$line" :…
ns533
  • 301
  • 1
  • 4
  • 13
0
votes
1 answer

Can't add more than 2 variables

I have a problem whenever I add more than 3 numbers with multiple operators. (I tried expr, bc, SUM=$(( $S1 + $S2 + $S3 )) and many other forms, but whenever I have 3 variables I get this error. expr: non-integer argument expr: syntax error This…
ellsusan
  • 91
  • 1
  • 1
  • 6
0
votes
1 answer

Calculating with AutoWikiBrowser

I'm using regular expression in AutoWikiBrowser to replace the input of several values with just one value, such as this: |value1=4 |value2=5 |value3=6 To this: |value={{#expr:4+5+6}} While the correct result does show on the page, it does not…
g0urra
  • 3
  • 2
0
votes
1 answer

How to convert a unescaped string to NSString in lldb?

Suppose I have a " aaaaa vnnvnvnvnv bbbbc " How can I convert it to a NSString and use it in next expression, normally I need to escape it use a tool first. I found the return char always break interpreter parse expression.
Karl
  • 665
  • 4
  • 19
0
votes
3 answers

expr bash for sed a line in log does not work

my goal is to sed the 100th line and convert it to a string, then separate the data of the sentence to word #!/bin/bash fid=log.txt; sentence=`expr sed -n '100p' ${fid}`; for word in $sentence do echo $word done but apparently this has failed.…
kensaii
  • 314
  • 5
  • 16
0
votes
4 answers

Bash index of first character not given

So basically something like expr index '0123 some string' '012345789' but reversed. I want to find the index of the first character that is not one of the given characters... I'd rather not use RegEx, if it is possible...
Emma
  • 430
  • 8
  • 14
0
votes
1 answer

expr: Regex not detecting valid expression

I'm trying to create a script that automatically looks for plugged in devices and makes a compressed backup of it. However, I'm having trouble finding the correct way on how to use expr: #!/bin/bash MountText=`mount` # Show result of regex…
Nolan Akash
  • 989
  • 8
  • 21
0
votes
2 answers

Bash expr command

I am trying to make a bash shell script that can add a name value pair to a text file, for example TEST=true. I am trying to make it so if the user tries to add a name that already exists for example TEST=false it does not let them to do it. Can…
mrblippy
  • 311
  • 2
  • 3
  • 10
0
votes
1 answer

TCL floating output of expr used with conditional operator '<' not working

I am using TCL 8.4 While the following works as expected, % if { 50.02 < 50.02 } { puts HI } % set s 50.02 50.02 % if { $s < 50.02 } { puts HI } % set high 50.02 50.02 % if { $s < $high } { puts HI } % % % if { 50.02 < $high } { puts HI } Why…
0
votes
1 answer

Symfony createQueryBuilder, how use 'and'/'andx' inside 'orx'

IS there a better way to build a complex query in Symfony 2? My real query is quite complex, but can be simplified to something like "A and ((B and C) or (B and D))" (I know math equation as "A and B and (C or D)", but my real query cannot be…
Bin Chen
  • 93
  • 1
  • 8
0
votes
1 answer

I am getting an syntax error when using expr

Here is the code: #!/bin/bash reg='[0-9]{1}-[0-9]{2}-[0-9]{6}-[0-9Xx]{1}' while read ISBN; do if [[ $ISBN =~ '$$$' ]]; then exit 0 else if [[ $ISBN =~ $reg ]]; then ISBN=${ISBN//-/} let sum=0 …
icecity96
  • 1,177
  • 12
  • 26
0
votes
2 answers

File reading, loops and expressions in Unix using Bourne shell

I was hoping someone could give me a hand. I'm just starting to learn shell scripting in Unix using the Bourne shell and I've run into a problem. I'm trying to make a script that takes a file with a series of digits and reads through it with a while…
user2904491
  • 11
  • 1
  • 2