DEV Community

Pratik Yadav
Pratik Yadav

Posted on

SHELL SCRIPTING

How to write basic script

#!/bin/bash
echo "This is my first script"
Enter fullscreen mode Exit fullscreen mode

On Linux, a shebang (#!) is a special line at the beginning of a script that tells the operating system which interpreter to use when executing the script. “/bin/bash” is tell the path of interpreter we are using.

“echo” is a Unix/Linux command tool used for displaying lines of text or string.

let take input from user

#!/bin/bash
echo "lets take input from user"
read userinput
echo "User Input : $userinput"
Enter fullscreen mode Exit fullscreen mode

The read command is a way for the users to interact with input taken from the keyboard.

In shell scripting, the dollar sign ($) is used to reference the value of a variable.

In this script, the dollar sign is used to reference the value of the userinputvariable. if user enter “Hello, World!” as input then When the script is executed, it will shows output:

output :

image showing output of code

uses of $ sign :

showing the details of $ sign in shellscript

Thank you for reading!

Top comments (0)