Write Your First Program In Shell Script - CodexRitik

Write Your First Program In Shell Script - CodexRitik

Let's write a shell script to print hello world.



  • Hello World Script
      hello.sh

  1.       Example
  • Code:

#Hello World Shell Script

echo "Hello World"                      #echo is use for Print a message



  • Output
sh hello.sh

Hello World




  • Write a shell script to take 2 arguments to print hello world
We are going to pass "Hello" and "World" as an argument to the shell script Instead of printing it directly.



  • Hello World Script
          hello.sh

  • Code:

#Hello World Shell Script

echo $1 $2


  • Output
sh hello.sh Hello World

Hello World


  • Explanation:
Command Line Arguments - While running the script, we need to pass the arguments after sh filename.sh.

$1 holds the argument 1 ("Hello").

$2 holds the argument 2 ("World").

  • Click For Image View:

                                                 



🙏THANKS FOR VISIT🙏


Next Article coming soon..............

Write Your First Program In Shell Script - CodexRitik Write Your First Program In Shell Script - CodexRitik Reviewed by CodexRitik on July 10, 2020 Rating: 5

No comments:

Powered by Blogger.