let कमांड
let एक helper को यह कहने जैसा है 'इसे work out करो और answer मेरे label पर लिख दो'। आप इसे एक छोटा sum देते हैं और यह result एक variable में store कर देता है।
In this page:
Syntax
let variable=expression
let
let एक arithmetic expression के result को evaluate और assign करता है एक variable को, $(( )) जैसा ही लेकिन एक standalone command के रूप में। let x=5+3 x को 8 set करता है बिना right-hand side पर $ की ज़रूरत के।
यह एक पुराना alternative है जो आज $(( )) या ((...)) से कम commonly उपयोग होता है।
Note:
((x = 5 + 3)) let x=5+3 का modern equivalent है और generally preferred है।उदाहरण: let
#!/bin/bash
let x=5+3
echo "x = $x"
let "y = x * 2"
echo "y = $y"
Login to try C/C++/Java/PHP code in the editor
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
letउपयोग करते समय=के आस-पास spaces लगाना, जैसेlet x = 5, जो fail होता है जब तक expression quoted न हो।letसे decimals के साथ काम करने की उम्मीद करना, जब यह integer only है।letउपयोग करना और यह भूल जाना कि 0 result exit status 1 देता है, जोset -eके साथ एक script को रोक सकता है।
🔒
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: