UPTO 50% OFF on All Courses | Offer Ends at Midnight | Use Coupon Code - FLAT50 During Checkout |Enroll Now
A shell script is a file containing a list of commands. Let's create a simple command that prints two words:
Open a text editor to create a file myfirstscript.sh:
Write the following into the editor:
#!/bin/bash name=linux echo "hello $name world"
Note: In Unix, the extension doesn't dictate the program to be used while executing a script. It is the first line of the script that would dictate which program to use. In the example above, the program is "/bin/bash" which is a Unix shell.
Press Ctrl +x to save and then "y" to exit
Now, by default, it would not have executable permission. You can make it executable like this:
chmod +x myfirstscript.sh
To run the script, use:
Taking you to the next exercise in seconds...