How to Run a Shell Script in Linux [Essentials Explained for Beginners]

There are two ways to run a shell script in Linux. You can use.

Or you can execute the shell script like this.

That maybe simple but it doesn8217t explain a lot. Don8217t worry I8217ll do the necessary explaining with examples so that you understand why a particular syntax is used in the given format while running a shell script.

I am going to use this one line shell script to make things as uncomplicated as possible.

The first method involves passing the script file name as an argument to the shell.

Considering that bash is the default shell you can run a script like this.

Do you know the advantage of this approach Your script doesn8217t need to have the execute permission. Pretty handy for quick and simple tasks.

If you are not familiar already I advise you to read my detailed guide on file permission in Linux.


Read Full Post

News Link:
RSS Link:

Linux Chatter is a news aggregator service that curates some of the best Linux, Cloud, Technical Guides, Hardware and Security news. We display just enough content from the original post to spark your interest. If you like the topic, then click on the 'read full post' button to visit the author's website. Use Linux Chatter to find content from amazing authors!

Note: The content provided has been modified and is not displayed as intended by the author. Any trademarks, copyrights and rights remain with the source.

Disclaimer: Linux Chatter sources content from RSS feeds and personal content submissions. The views and opinions expressed in these articles are those of the authors and do not necessarily reflect those of Linux Chatter.