Scripts चलाना
एक script run करना एक cook को एक recipe हाथ में देने जैसा है: आप हर बार 'यह recipe follow कीजिए' कह सकते हैं, या इस पर एक note चिपका सकते हैं जो कहता है कि cook इसे अपने आप उपयोग कर सकता है।
In this page:
Syntax
bash script_name.sh
chmod +x script_name.sh
./script_name.sh
Scripts Run करना
एक Bash script दो तरीकों से run होता है: इसे सीधे bash interpreter को pass करके, या इसे executable बनाकर अपने खुद के program की तरह run करके।
bash script.sh permissions को देखे बिना हमेशा काम करता है। इसे सीधे ./script.sh के रूप में run करने के लिए पहले file पर execute permission चाहिए।
Note:
bash script.sh बिना execute permission के भी काम करता है, क्योंकि आप explicitly bash को invoke कर रहे हैं।उदाहरण: Running Scripts
# Run with the interpreter directly
bash script.sh
# Or make it executable and run it directly
chmod +x script.sh
./script.sh
⚠️ Run this in your own terminal or Node.js environment.
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. #}
आम गलतियां
hello.shको बिना./के run करना, इसलिए shellPATHमें देखता है और current directory में मौजूद script के लिएcommand not foundreport करता है।./hello.shको बिना execute permission के run करना, जोPermission deniedदेता है;chmod +xयाbash hello.shउपयोग करें।- एक script को
sh script.shसे run करना और Bash features की उम्मीद करना, क्योंकिshएक simpler shell हो सकता है।
🔒
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: