Shebang Line का परिचय
Shebang एक lunchbox पर नाम के label जैसा है जो बताता है कि इसे कौन खोलेगा। यह computer को बताता है कि file को कौन सा helper program पढ़े और run करे।
In this page:
Syntax
#!/path/to/interpreter
# script commands follow
The Shebang Line
एक script की पहली line, #!/bin/bash, shebang है — यह operating system को बताती है कि सीधे execute होने पर file को कौन सा interpreter run करे।
इसके बिना, ./script.sh गलत shell उपयोग कर सकता है और unexpectedly behave कर सकता है। Shebang बिल्कुल पहली line होनी चाहिए, इसके ऊपर कोई blank line नहीं।
Note:
#!/usr/bin/env bash एक ज़्यादा portable shebang है जो bash को PATH पर जहां भी हो ढूंढ लेता है।उदाहरण: The Shebang Line
#!/bin/bash
# This shebang tells the OS to run this file with bash
echo "Running under: $0"
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. #}
आम गलतियां
#!से पहले एक space या blank line लगाना, इसलिए यह shebang के रूप में नहीं पढ़ा जाता और system एक default shell उपयोग करता है।#!/bin/bshजैसा गलत interpreter path लिखना, जोbad interpreter: No such file or directoryदेता है।- Script को Windows line endings (CRLF) के साथ save करना, इसलिए interpreter
bash\rके रूप में पढ़ा जाता है और fail हो जाता है।
🔒
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: