AnyCompiler

Aapki Pehli Bash Script

Ek Bash script usually shebang line se shuru hoti hai, #!/bin/bash, jo system ko batati hai ki file ko kaunsa interpreter run kare. Uske 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, exactly Python jaisa. Yeh sirf isliye hote hain ki baad mein script padhne wale insaan samajh sakein ki koi cheez us tareeke se kyun likhi gayi hai — Bash khud inhe poori tarah ignore karta hai.

Khud run karo

Yeh hai ek chhoti script jisme shebang, ek comment, aur do echo calls hain. Yeh actually execute hui thi taaki neeche dikhaya gaya output mile — example ke neeche diye button se text change karke khud run karke dekho.

#!/bin/bash
# This is a comment -- ignored by Bash
echo "Hello, world!"
echo "Learning Bash one step at a time."
Output
Hello, world!
Learning Bash one step at a time.

Aage: variables — assignment syntax, aur ek real mistake jo har Bash beginner se kam se kam ek baar ho jaati hai.

Practice exercise

echo line ke upar ek comment add karo jo describe kare ki script kya karti hai (comment khud koi output produce nahi karta), phir exactly yeh print karo: Learning Bash one step at a time.