Shell Script in Linux In Hindi

Shell scripting mein command substitution, expressions, arithmetic operators, logical operators, test expressions, read statement, aur test command important concepts hain. Yahan main aapko in sabhi concepts ke baare mein thoda detail mein batata hoon:

Shell Script in Linux In Hindi

1. Command Substitution command in linux in hindi:

Command substitution shell scripts mein ek command ya subshell ko run karke uska output variable mein store karne ka tareeka hai. Iske liye aap $(command) syntax ka istemal kar sakte hain.

For example:

current_date=$(date)
echo "Current date is $current_date"

2. Expressions command in linux in hindi:

Expressions shell scripts mein variables, constants, aur operators ka combination hota hai jinka result ek value hota hai. Expressions ko use karke calculations aur comparisons kiye ja sakte hain.

3. Arithmetic Operators command in linux in hindi:

Shell scripts mein arithmetic operations ke liye kuch operators available hain, jaise ki:

  • +: Addition
  • -: Subtraction
  • *: Multiplication
  • /: Division
  • %: Modulus

For example:

result=$((5 + 3))
echo "Result is $result"

4. Logical Operators command in linux in hindi:

Logical operators, jaise ki && (logical AND), || (logical OR), aur ! (logical NOT), shell scripts mein conditions ke evaluation mein use hote hain.

For example:

if [ $age -ge 18 ] && [ "$gender" == "Male" ]; then
  echo "You are an adult male."
fi

5. Test Expressions command in linux in hindi:

Shell mein test expressions ko evaluate karne ke liye test command ya [ ] square brackets ka istemal hota hai. Isse aap conditions check kar sakte hain.

For example:

if [ -f "$filename" ]; then
  echo "$filename exists."
fi

6. Read Statement command in linux in hindi:

read statement ka istemal user input ko read karne ke liye hota hai. Isse aap user se information input le sakte hain aur usko variable mein store kar sakte hain.

For example:

echo -n "Enter your name: "
read name
echo "Hello, $name!"

7. Test Command command in linux in hindi:

test command ko conditional expressions evaluate karne ke liye istemal kiya jata hai. Isse aap file existence, string comparison, aur numerical comparisons kar sakte hain.

For example:

if test $age -ge 18; then
  echo "You are an adult."
fi

In concepts ka istemal shell scripts mein logic aur user interaction ko control karne ke liye hota hai. Aap in concepts ka istemal karke shell scripts ko dynamic aur functional bana sakte hain.

Leave a Comment