Aap Ki Pehli Bash Script
Ek Bash script usually shebang line se shuru hoti hai, #!/bin/bash, jo system ko batati hai ke file ko kaunsa interpreter run kare. Us ke baad har line directly, top se bottom tak, script start hote hi run hoti hai — koi separate compile step nahi hota jaise ek compiled language mein hota hai, aur pehle define karne ko koi main function nahi hai.
Comments
Comments # se start hote hain aur line ke end tak chalte hain, bilkul Python jaisa. Yeh sirf isliye hote hain ke baad mein script parhne wale log samajh sakein ke koi cheez us tareeke se kyun likhi gayi hai — Bash khud inhe poori tarah ignore karta hai.
Khud Run Karein
Yeh hai ek chhoti script jis mein shebang, ek comment, aur do echo calls hain. Yeh waqai execute hui thi taake neeche dikhaya gaya output mile — example ke neeche diye button se text change kar ke khud run kar ke dekhein.
#!/bin/bash # This is a comment -- ignored by Bash echo "Hello, world!" echo "Learning Bash one step at a time."
Hello, world! Learning Bash one step at a time.
Aage: variables — assignment syntax, aur ek real mistake jo har Bash beginner se kam az kam ek baar ho jati hai.
Practice exercise
echo line ke upar ek comment add karein jo describe kare ke script kya karti hai (comment khud koi output produce nahi karta), phir exactly yeh print karein: Learning Bash one step at a time.