Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Operating System
Help improving .sh script
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="vansmith" data-source="post: 1421076" data-attributes="member: 71075"><p>You can easily pick up on parameters in a bash script. You can pass nine in total and they are numbered. So, if you want to get the first parameter, you can manipulate the $1 variable. Let's look at an example:</p><p></p><p>Here I've got a very simple script:[code]echo Hello $1[/code]It does nothing but echo back "Hello" and the first parameter sent to the script. If I run the following command (pretend I called it test.sh):[code]sh test.sh vansmith[/code]I get the following in response: "Hello vansmith". If you pass it nothing, you would just get "Hello".</p></blockquote><p></p>
[QUOTE="vansmith, post: 1421076, member: 71075"] You can easily pick up on parameters in a bash script. You can pass nine in total and they are numbered. So, if you want to get the first parameter, you can manipulate the $1 variable. Let's look at an example: Here I've got a very simple script:[code]echo Hello $1[/code]It does nothing but echo back "Hello" and the first parameter sent to the script. If I run the following command (pretend I called it test.sh):[code]sh test.sh vansmith[/code]I get the following in response: "Hello vansmith". If you pass it nothing, you would just get "Hello". [/QUOTE]
Verification
Post reply
Forums
Apple Computing Products:
macOS - Operating System
Help improving .sh script
Top