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

Treat argument as string in Tcl 'expr' statement

I'm using the short syntax of 'if' statement like this: proc WriteParameter {Parameter Value} { # Ugly option - WORKS if {$Parameter eq "Unique"} { set Register ControlStatus set Data ${Value}0 set Mask EF } else…
HardwareEng.
  • 99
  • 1
  • 14
0
votes
2 answers

Error "expr: command not found" in bourne script

I am building a bourne script for a class, and am encountering an issue with this loop. Basically I am building a loop to go through all the files in a specified directory and determine how many files and directories there are as well as how many…
neomang
  • 117
  • 3
  • 10
0
votes
1 answer

unix expr: syntax error

Why is the following expression giving me a expr: syntax error? pingval=`expr ping6 -c 1 "$url"` Basically I want to use the value returned by the above expression in another expression e.g. var=$($pingval|tail -1 .... Any suggestions?
user3352349
  • 177
  • 2
  • 4
  • 16
-1
votes
1 answer

Using shell variable to select awk column identifier

This one works: temp=($(awk -F" " '$2 == 84' "$1".db)) This one does not (fieldnumber stores the column i wish to search, and val stores the value I'm searching for): temp=($(awk -F" " -v column="$""$field_number" -v val="$3" '{ if(column == val)…
-1
votes
1 answer

Tcl lindex and expr: non-numeric failure

If I put only below it works. "\{[lindex ($columns) 1] - 30.3]" If I put as below, it doesnt work. Wonder why? "\{[lindex ($columns) 1] - 30.3] [expr [lindex ($columns) 2] -30.3] \}" My script as below: foreach line $lines { set columns [split…
Kimi
  • 43
  • 1
  • 7
-1
votes
3 answers

How to retrieve the variable name “apple” in "FRUIT=apple" in UNIX shell?

When the user inputs FRUIT=apple in the Unix shell, how can I get the name FRUIT and apple from the input FRUIT=apple separately? echo -e "\nEnter inputs here: \c" read inputs ## user input "FRUIT=apple" Is there any way to get a partial text from…
-1
votes
2 answers

tcl expr not rounding like i expect

Im new to tcl and i have these numbers: set a 565056236086 set b 488193341805 the output of $a / $b is 1,157443552992375 When i use the following code set num [expr {double(round(100*$a / $b))/100}] the output is: 1,15 but i want 1.16 how can i…
-1
votes
1 answer

shell non integer argument in expr error

I wrote the following code in shell script: num=$1 sum=0; rn=0 less=0; fact=0 while [ $num -gt 0 ] do rn=`expr $num % 10` num=`expr $num / 10` while [ $rn -gt 1 ] do less=`expr %rn - 1` fact=`expr $rn \* less` rn=`expr $rn - 1` done sum=`expr $sum…
Richi Dubey
  • 89
  • 12
-1
votes
1 answer

Downloading basic Linux commands

I have a basic Linux distribution on a router. I'd like to install libmodbus to handle some modbus controls locally. However, the Linux distribution lacks the expr command. When I run ./configure to install the package, I get a bunch of errors like:…
Lost Puppy
  • 19
  • 6
-1
votes
2 answers

Unix Shell Scripting - expr syntax issue

I am trying to find total size of a current directory and the shell script is failing at expr command. below is my code: #!/bin/sh echo "This program summarizes the space size of current directory" sum=0 for filename in *.sh do fsize=`du -b…
Ravi
  • 163
  • 1
  • 2
  • 12
-1
votes
1 answer

How do I convert a calculated field in crystal reports into an SSRS expression?

I have a calculated field in crystal reports, which I need to convert it to an SSRS expression. Any help would be appreciated. If ({VISIT_TYPE.DESCRIPTION} = "New" or {VISIT_TYPE.DESCRIPTION} = "Walk-In New") then if {ATTEND_STATUS.DESCRIPTION}…
Devesh Sharma
  • 25
  • 1
  • 7
-2
votes
2 answers

Add 1-10 minutes on every column of a file and file have n number of times

i have a time file like this time.log 12:30 13:10 16:00 and i want to redirect this file in this…
1 2 3 4 5 6
7