Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about let and log command

Status
Not open for further replies.

hokky

Technical User
Nov 9, 2006
170
AU
Hi There,

can someone tell me what let and log command for in here ?
Code:
if [ $result -eq 1 ]; then

        let "max_run_sec = $var * 60"
        let "actual_start_time = $(date +%s)"
        let "expected_end_time = $actual_start_time + $max_run_sec"

        log "TIMENOW : $actual_start_time"
        log "MAXEXEC : $max_run_sec secs"
        log "ENDTIME : $expected_end_time"

else
        log "ENDTIME : Not specified"
fi
 
Hi,

What shell are you using ?
In ksh, let is a shell builtin
log is perhaps a user function defined somewhere else.
use whence -v log and whence -v let to know more about this commands
Ali
 
Thanks aau,

yeah.. log is function defined.

But let is shell builtin, his using bash shell.

Any idea why ?
 
bash apparently allows let as an alternative to using expr in other shells.

Alan Bennett said:
I don't mind people who aren't what they seem. I just wish they'd make their mind up.
 
Hi

In [tt]bash[/tt] the [tt]let[/tt] built-in is equivalent of the two parenthesis ( () ) evaluation :
Code:
[blue]master #[/blue] i=1

[blue]master #[/blue] let i++

[blue]master #[/blue] echo $i
2

[blue]master #[/blue] ((i++))

[blue]master #[/blue] echo $i
3

Feherke.
 
ksh knows let also (at least I know on AIX it does - or used to - I haven't tried it for ages)

let a=10

is equivalent to

(( a=10 ))


HTH,

p5wizard
 
Like the guys have already said

let

The let command evaluates integer arithmatic expressions. Expressions can contain constants, shell variables (which don't have to be preceded by $) and operators. Valid operators are

- unary minus
! ~ logical negation, bitwise NOT
* / % multiplication, division, remainder
+ - addition, subtraction
<< >> left shift, right shift
<= >= < > comparision
== != equal, not equal
& bitwise and
^ bitwise exclusive or
| logical or
&& logical and
|| logical or
= assignment

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
ok.. thx guys. i thought let is same as expr in bash.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top