This purpose of this article is for testing my simple shell script in Linux.
Steps:
- Create a simple shell script
- Execiting script shell in terminal
It’s simple. Let’s get started!
Create a simple shell script
To craete a shell script: vim name
- You can type below examples for testing your script.
Note: “vim” provides another verifications of programming language comapred with “vi”. Although you can use both to create your shell script.
Example 1:
1 | echo "Hello $USER." |
Example 2:
1 | echo "What is your name?" |
- After typing your shell script, save it.
To save it, press “Esc” to exit the insert mode and type “:w” to save the script.
Type “:q” getting back to the console and execute the shell file to show output in the terminal.
“ls” to check if the shell script had been created successfully.
To execute a shell script
“bash” to execute the schell script
Follow above simple steps to run your own script. :P