आपकी पहली Script
आपकी पहली script अपनी पहली तीन-step recipe लिखने जैसी है: top पर एक label, कुछ instructions, और यह याद रखने के लिए notes कि क्यों। इसे save करें, run करें, और computer को साथ follow करते देखें।
In this page:
Syntax
#!/bin/bash
# describe what the script does
variable_name="value"
echo "message with $variable_name"
Your First Script
एक complete पहली script shebang, कुछ commands, और intent explain करने वाले comments को combine करती है। इसे .sh extension के साथ save करना एक convention है, requirement नहीं — Bash file extensions की care नहीं करता।
जो मायने रखता है वह है shebang line और execute permission।
Note:
अपनी पहली scripts छोटी रखें और उन्हें बहुत सारे commands लिखने से पहले बार-बार test करें, run करने से पहले नहीं।
उदाहरण: Your First Script
#!/bin/bash
# My first Bash script
echo "Starting script..."
name="World"
echo "Hello, $name!"
echo "Script finished."
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. #}
आम गलतियां
- Script के top पर
#!/bin/bashline भूल जाना। - Script को executable बनाना भूल जाना, फिर
Permission deniedमिलना। - Script के अंदर एक relative path उपयोग करना और इसे किसी और directory से run करना, इसलिए files नहीं मिलतीं।
🔒
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: