<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bash Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/bash/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Sat, 27 Feb 2021 09:53:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>Top 10 Scripting Languages in DevOps &#124; List of Best Scripting Languages</title>
		<link>https://www.scmgalaxy.com/tutorials/top-10-scripting-languages-in-devops/</link>
					<comments>https://www.scmgalaxy.com/tutorials/top-10-scripting-languages-in-devops/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Thu, 27 Apr 2017 23:04:16 +0000</pubDate>
				<category><![CDATA[Programming Scripting Languages]]></category>
		<category><![CDATA[Ansible]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Best]]></category>
		<category><![CDATA[Best scripting languages]]></category>
		<category><![CDATA[Chef]]></category>
		<category><![CDATA[Devops]]></category>
		<category><![CDATA[Go language]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[List of scripting languages]]></category>
		<category><![CDATA[Microsoft PowerShell]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Scripting Language]]></category>
		<category><![CDATA[Top]]></category>
		<category><![CDATA[Top scripting languages]]></category>
		<category><![CDATA[What]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2017/04/27/top-10-scripting-languages-in-devops/</guid>

					<description><![CDATA[<p>This is the time of DevOps in software industry and DevOps uses different different languages for deployment automation and for [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/top-10-scripting-languages-in-devops/">Top 10 Scripting Languages in DevOps | List of Best Scripting Languages</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img fetchpriority="high" decoding="async" class="size-full wp-image-2906 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/top-10-scripting-languages-.png" alt="top-10-scripting-languages-in-devops" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/top-10-scripting-languages-.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/top-10-scripting-languages--300x200.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></div>
<div></div>
<div style="text-align: justify;">This is the time of DevOps in software industry and DevOps uses different different languages for deployment automation and for software development. This is the reason if you are a DevOps professional and want to be succeed in DevOps role than command on scripting languages is must. But, one can not be a master of all. Right? Therefore, In this article I am going to share a list of top 10 scripting languages which will be useful for your DevOps journey.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">But before that let&#8217;s have a quick look on Scripting language.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Scripting languages are programming languages that communicate and integrate with other programming languages. In other words, scripting languages controlls interactive programs operations by giving it sequence of work to execute by one command at a time.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Now, let&#8217;s look on to the list of top 10 scripting languages</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<p><strong>1. Microsoft PowerShell</strong></p>
<p><img decoding="async" class="alignnone wp-image-652 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/powershell-language.png" alt="Microsoft PowerShell" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/powershell-language.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/powershell-language-300x167.png 300w" sizes="(max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>Microsoft powershell</strong> or powershell is belongs to Microsoft and an open source cross platform scripting language. If you have application infrastructure with windows than powershell is must for you. This scripting language is designed for system admins.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>2. Puppet</strong></div>
<div style="text-align: justify;">
<p><img decoding="async" class="alignnone wp-image-653 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/puppet-language.png" alt="Puppet" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/puppet-language.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/puppet-language-300x167.png 300w" sizes="(max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Puppet</strong> is a configuration management tool and it has it&#8217;s own declarative language to describe system configuration. It runs on Linux, Unix-like and also on Windows. This one is available under Apache 2.7.0 and General Pubic license.  Puppet uses a custom declarative language, it just needs to specify ‘what’ action needs to be performed on the resources.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>3. Chef</strong></div>
<div style="text-align: justify;">
<p><img loading="lazy" decoding="async" class="alignnone wp-image-654 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/chef-language.png" alt="Chef" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/chef-language.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/chef-language-300x167.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Chef</strong> is basically known as configuration management which belongs to chef is also a scripting language which is designed by David Morgan. It makes programs look like cooking any food.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>4. Bash</strong></div>
<div style="text-align: justify;">
<p><img loading="lazy" decoding="async" class="alignnone wp-image-655 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/bash-scripting.png" alt="Bash" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/bash-scripting.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/bash-scripting-300x167.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Bash</strong> is basically a command language which is available in open source and written by Brian Fox in the year 1989. It can read scripts and Bash is the most commonly used Unix shell. Bash supports Linux, Windows and Mac OS.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>5. Ruby</strong></div>
<div style="text-align: justify;">
<p><img loading="lazy" decoding="async" class="alignnone wp-image-656 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/ruby-language.png" alt="Ruby" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/ruby-language.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/ruby-language-300x167.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Ruby</strong> is amongst one of the best programming language but it is also a scripting language which is written by Yukihiro Matsumoto in the year 1995. Ruby supports cross platforms and it is available under GPL and BSD license. It supports multiple programming paradigms, including functional, object-oriented, and imperative.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>6. Ansible</strong></div>
<div style="text-align: justify;">
<p><img loading="lazy" decoding="async" class="alignnone wp-image-657 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/ansible-langugae.png" alt="Ansible" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/ansible-langugae.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/ansible-langugae-300x167.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Ansible</strong> is known as configuration management and application deployment tool but it is also amongst top scripting languages. This language is belongs to Ansible Inc. and written by their community members. It supports Linux, Unix-like and Windows operating system.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>7. Perl</strong></div>
<div style="text-align: justify;">
<p><img loading="lazy" decoding="async" class="alignnone wp-image-658 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/perl-language.png" alt="Perl" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/perl-language.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/perl-language-300x167.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Perl</strong> is a scripting language which is used for advanced web applications development. Perl is written by Larry Wall and first released in the year 1987. Perl supports cross platforms. Perl is available under general public license.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>8. Python</strong></div>
<div style="text-align: justify;">
<p><img loading="lazy" decoding="async" class="alignnone wp-image-659 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/python-language.png" alt="Python" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/python-language.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/python-language-300x167.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Python</strong> is also amongst the top scripting languages which is used for high level of programming. It was first released in the year 1991 by Guido van Rossum. python is available under Python Software Foundation License. It&#8217;s supports Cross-platform.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>9. Go language</strong></div>
<div style="text-align: justify;">
<p><img loading="lazy" decoding="async" class="alignnone wp-image-660 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/go-language.png" alt="Go language" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/go-language.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/go-language-300x167.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Go scripting</strong> language belongs to the Internet giant Google. This scripting language is written by Robert Griesemer, Rob Pike and Ken Thompson and it was released in the year 2009. It supports  Linux, macOS, FreeBSD, NetBSD, OpenBSD, Windows, Plan 9, DragonFly BSD and Solaris operating systems. It is available in open source.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><strong>10. Groovy</strong></div>
<div style="text-align: justify;">
<p><img loading="lazy" decoding="async" class="alignnone wp-image-661 size-full" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/groovy-lang.png" alt="Groovy" width="450" height="250" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/groovy-lang.png 450w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2017/04/groovy-lang-300x167.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></p>
</div>
<div style="text-align: justify;"><strong>Groovy</strong> can be used as a scripting language and it is also consider as a top scripting languages for DevOps professionals. It was designed by James Strachan and developed by Guillaume Laforge, Jochen Theodorou, Paul King and Cedric Champeau. It was first released in the year 2003 and available under Apache license. It supports Java platform.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Do you agree with this list? If not than feel free to respond in the comment box with your own take on the most essential scripting languages. One more thing, I would like to add here, if you need help to learn all these scripting languages and DevOps courses than scmGalaxy can help you in this. <a href="courses/index.html" target="_blank" rel="noopener"><strong>scmGalaxy</strong> </a>is a community of DevOps professionals who are well experienced in this domain.</div>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/top-10-scripting-languages-in-devops/">Top 10 Scripting Languages in DevOps | List of Best Scripting Languages</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/top-10-scripting-languages-in-devops/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to get bash or ssh into a running container in background mode?</title>
		<link>https://www.scmgalaxy.com/tutorials/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Tue, 23 Feb 2016 11:51:34 +0000</pubDate>
				<category><![CDATA[CONTAINERS]]></category>
		<category><![CDATA[Background]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Container]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[mode]]></category>
		<category><![CDATA[Running container]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[SSH into a Container]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2016/02/23/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode/</guid>

					<description><![CDATA[<p>How to get bash or ssh into a running container in background mode? Step 1: First of all, try to [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode/">How to get bash or ssh into a running container in background mode?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img loading="lazy" decoding="async" class="wp-image-3196 size-full aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2016/02/bash-or-ssh-into-a-running-1-1.png" alt="bash-or-ssh-into-a-running-container" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2016/02/bash-or-ssh-into-a-running-1-1.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2016/02/bash-or-ssh-into-a-running-1-1-300x200.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></div>
<div><strong>How to get bash or ssh into a running container in background mode?</strong></div>
<div></div>
<div><strong>Step 1: First of all, try to find your active container by running</strong></div>
<div># docker ps</div>
<div>or</div>
<div># docker ps -a</div>
<div></div>
<div><strong>Step 2: If the container is not running,</strong></div>
<div># docker start your_id</div>
<div></div>
<div><strong>Step 3: If we use attach we can use only one instance of shell.</strong></div>
<div># sudo docker attach 665b4a1e17b6 #by ID</div>
<div>or</div>
<div># sudo docker attach loving_heisenberg #by Name</div>
<div></div>
<div>If we want open new terminal with new instance of container&#8217;s shell, we just need run the following:</div>
<div># sudo docker exec -i -t 2e56ad1705b1 /bin/bash #by ID</div>
<div>or</div>
<div># sudo docker exec -i -t loving_heisenberg /bin/bash #by Name</div>
<div># root@665b4a1e17b6:/#</div>
<div></div>
<div><strong>Step 4: To exit bash without leaving bash running in a rogue process</strong></div>
<div># exit</div>
<div></div>
<div><strong>Notes:</strong></div>
<div>A reminder for boot2docker users: remove sudo</div>
<div>If you are using docker in Linux, you will have to use sudo along with docker commands.</div>
<div>You should try not to run commands as sudo, rather add your user to the docker group and just run normally.</div>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode/">How to get bash or ssh into a running container in background mode?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Shell Scripting (Bash) Training &#124; Bash/Shell Scripting Course</title>
		<link>https://www.scmgalaxy.com/tutorials/shell-scripting-bash-training-2/</link>
					<comments>https://www.scmgalaxy.com/tutorials/shell-scripting-bash-training-2/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Wed, 17 Jun 2015 22:21:54 +0000</pubDate>
				<category><![CDATA[Training]]></category>
		<category><![CDATA[Bangalore]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Bash Course]]></category>
		<category><![CDATA[Bash Scripting Course]]></category>
		<category><![CDATA[Bash Training]]></category>
		<category><![CDATA[Build]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Courses]]></category>
		<category><![CDATA[Delivery]]></category>
		<category><![CDATA[Devops]]></category>
		<category><![CDATA[Engineer]]></category>
		<category><![CDATA[Hyderabad]]></category>
		<category><![CDATA[India]]></category>
		<category><![CDATA[Online]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Shell Course]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Shell Scripting Course]]></category>
		<category><![CDATA[Shell Scripting Training]]></category>
		<category><![CDATA[Shell Training]]></category>
		<category><![CDATA[Trainer]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Usa]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2015/06/17/shell-scripting-bash-training-2/</guid>

					<description><![CDATA[<p>Introduction Introduction Why Shell Scripting? Linux Internal What to Expect From This Course? Prerequisites Git fundamental Introduction of git Git [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/shell-scripting-bash-training-2/">Shell Scripting (Bash) Training | Bash/Shell Scripting Course</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3459 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/06/shell-bash-training.png" alt="shell-bash-scripting-training" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/06/shell-bash-training.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2015/06/shell-bash-training-300x200.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></p>
<p><a title="DevOps Training Registration" href="events/register/index.html" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class=" size-full wp-image-1" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2014/07/registernow.jpg" alt="" width="232" height="104" /></a></p>
<p>Introduction</p>
<ul>
<li>Introduction</li>
<li>Why Shell Scripting?</li>
<li>Linux Internal</li>
<li>What to Expect From This Course?</li>
<li>Prerequisites</li>
</ul>
<p>Git fundamental</p>
<ul>
<li>Introduction of git</li>
<li>Git setup</li>
<li>Basic operations in git</li>
<li>Github</li>
<li>Summary</li>
</ul>
<p>A First Look At Shell Scripts</p>
<ul>
<li>Introduction</li>
<li>Creating A Shell Script</li>
<li>Demo: A Note-Taking Script</li>
<li>Calling The Script</li>
<li>The Shebang</li>
<li>Naming Your Script</li>
<li>Demo: The type Command</li>
<li>Summary</li>
</ul>
<p>Variables</p>
<ul>
<li>Introduction</li>
<li>Demo: Variables</li>
<li>Using Variables in A Script</li>
<li>Using Variables: Good Habits</li>
<li>Reading Input</li>
<li>Debugging your Script</li>
<li>Summary</li>
</ul>
<p>If, Then, Else</p>
<ul>
<li>Introduction</li>
<li>Demo: The If Statement</li>
<li>The If Statement</li>
<li>Return codes</li>
<li>The Conditional Expression</li>
<li>Demo: The Conditional Expression</li>
<li>The Conditional Expression 2</li>
<li>Arithmetic Tests</li>
<li>Demo: Arithmetic Tests</li>
<li>The If Statement Revisited</li>
<li>And, Or, Not</li>
<li>Summary</li>
</ul>
<p>Input and Output</p>
<ul>
<li>Introduction</li>
<li>Output: echo and printf</li>
<li>Input: read revisited</li>
<li>Standard Streams and Redirection</li>
<li>Demo: Redirection</li>
<li>Summary</li>
</ul>
<p>Control Flow</p>
<ul>
<li>Introduction</li>
<li>While and Until</li>
<li>The Classic For Statement</li>
<li>The C-Style For Statement</li>
<li>Break and Continue</li>
<li>The Case Statement</li>
<li>&amp;&amp; and ||</li>
<li>Summary</li>
</ul>
<p>Variables 2</p>
<ul>
<li>Introduction</li>
<li>Integer Variables</li>
<li>Arithmetic Expressions</li>
<li>Arithmetic Expressions 2</li>
<li>Read-only Variables</li>
<li>Exporting Variables</li>
<li>Arrays</li>
<li>Summary</li>
</ul>
<p>Handling Script Parameters</p>
<ul>
<li>Introduction</li>
<li>Special Variables</li>
<li>Shift</li>
<li>Getopts</li>
<li>Getopts: Handling Errors</li>
<li>Summary</li>
</ul>
<p>Shell Functions</p>
<ul>
<li>Introduction</li>
<li>Shell Functions</li>
<li>Shell Functions 2</li>
<li>Functions: Demo</li>
<li>Some Miscellaneous Remarks</li>
<li>Summary</li>
</ul>
<p>Fun with Strings</p>
<ul>
<li>Introduction</li>
<li>Removing Part Of A String</li>
<li>Search and Replace</li>
<li>Setting A Default Value</li>
<li>Conditional Expression Patterns</li>
<li>Regular Expressions in The Conditional Expression</li>
<li>End of Options</li>
<li>Summary</li>
</ul>
<p>Many Ways to Run Your Script</p>
<ul>
<li>Introduction</li>
<li>Running your Code</li>
<li>Nohup and The Background</li>
<li>Exec</li>
<li>At and Cron</li>
<li>Set and Shopt</li>
<li>Summary</li>
</ul>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/shell-scripting-bash-training-2/">Shell Scripting (Bash) Training | Bash/Shell Scripting Course</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/shell-scripting-bash-training-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>BASH aliases for GIT &#124; Bash Git Aliases Reference</title>
		<link>https://www.scmgalaxy.com/tutorials/bash-aliases-for-git/</link>
					<comments>https://www.scmgalaxy.com/tutorials/bash-aliases-for-git/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Wed, 11 Apr 2012 00:00:00 +0000</pubDate>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Aliases]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Bash alias]]></category>
		<category><![CDATA[BASH aliases for GIT]]></category>
		<category><![CDATA[Bash Git Aliases]]></category>
		<category><![CDATA[Bash Git Aliases Reference]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Git aliases]]></category>
		<category><![CDATA[Git Bash Aliases]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2012/04/11/bash-aliases-for-git/</guid>

					<description><![CDATA[<p>BASH aliases for GIT Following BASH aliases can be used in ~/.BASHRC alias g = &#8220;git status&#8221; alias ga = [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/bash-aliases-for-git/">BASH aliases for GIT | Bash Git Aliases Reference</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3842 aligncenter" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2012/04/bash-aliases-for-git.png" alt="bash-aliases-for-git" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2012/04/bash-aliases-for-git.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2012/04/bash-aliases-for-git-300x200.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></p>
<p><strong>BASH aliases for GIT</strong></p>
<p>Following BASH aliases can be used in ~/.BASHRC</p>
<p>alias g = &#8220;git status&#8221;<br />
alias ga = &#8220;git add&#8221;<br />
alias gaa = &#8220;git add .&#8221;<br />
alias gc = &#8220;git commit -m&#8221;<br />
alias gca = &#8220;git commit -am&#8221;<br />
alias gb = &#8220;git branch&#8221;<br />
alias gbd = &#8220;git branch -d&#8221;<br />
alias gco = &#8220;git checkout&#8221;<br />
alias gcob = &#8220;git checkout -b&#8221;<br />
alias gm = &#8220;git merge&#8221;<br />
alias gr = &#8220;git rebase&#8221;<br />
alias gl = &#8220;git log&#8221;<br />
alias gs = &#8220;git show&#8221;<br />
alias gd = &#8220;git diff&#8221;<br />
alias gbl = &#8220;git blame&#8221;<br />
alias gps = &#8220;git push&#8221;<br />
alias gpl = &#8220;git pull&#8221;</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/bash-aliases-for-git/">BASH aliases for GIT | Bash Git Aliases Reference</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/bash-aliases-for-git/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understand Shell Script Parameters &#8211; Reference</title>
		<link>https://www.scmgalaxy.com/tutorials/shell-script-parameters/</link>
					<comments>https://www.scmgalaxy.com/tutorials/shell-script-parameters/#respond</comments>
		
		<dc:creator><![CDATA[scmgalaxy K]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 15:18:51 +0000</pubDate>
				<category><![CDATA[Shell Script]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Bash Positional Parameter]]></category>
		<category><![CDATA[Bash shell]]></category>
		<category><![CDATA[bash shell script parameters]]></category>
		<category><![CDATA[Bash Special Parameters]]></category>
		<category><![CDATA[Parameters]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[shell parameter values]]></category>
		<category><![CDATA[Shell script]]></category>
		<category><![CDATA[shell script arguments example]]></category>
		<category><![CDATA[Shell Script Parameters]]></category>
		<category><![CDATA[Shell Script Parameters Guide]]></category>
		<category><![CDATA[Shell Script Parameters Instructions]]></category>
		<category><![CDATA[Shell Script Parameters Reference]]></category>
		<category><![CDATA[shell script pass parameter]]></category>
		<category><![CDATA[Understand Shell Script Parameters]]></category>
		<guid isPermaLink="false">http://www.scmgalaxy.com/tutorials/2010/12/10/shell-script-parameters/</guid>

					<description><![CDATA[<p>A parameter is an entity that stores values. It can be a name, a number or some special characters. Bash [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/shell-script-parameters/">Understand Shell Script Parameters &#8211; Reference</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4336" src="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2010/12/shell-script-parameters.png" alt="shell-script-parameters" width="600" height="400" srcset="https://www.scmgalaxy.com/tutorials/wp-content/uploads/2010/12/shell-script-parameters.png 600w, https://www.scmgalaxy.com/tutorials/wp-content/uploads/2010/12/shell-script-parameters-300x200.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></p>
<p><span style="font-size: 9pt; line-height: 115%;">A parameter is an entity that stores values. It can be a name, a number or some special characters. </span></p>
<p class="MsoNormal"><span style="font-size: 9pt; line-height: 115%;">Bash shell provides two kind of parameters.</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; line-height: 115%;">Positional Parameter and Special Parameter</span></p>
<p class="MsoNormal"><strong><em><span style="text-decoration: underline;"><span style="font-size: 9pt; line-height: 115%;">Bash Positional Parameter – $0, $1, $2 ..</span></span></em></strong></p>
<p class="MsoNormal"><span style="font-size: 9pt; line-height: 115%;">Positional parameters are the arguments given to your scripts when it is invoked. It could be from $1 to $N. When N consists of more than a single digit, it must be enclosed in a braces like ${N}.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">The <strong>variable $0 is the basename</strong> of the program as it was called.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">The following example gets two arguments and provides arithmetic operations result between those two integers.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">First, create the arithmetic.sh shell script as shown below.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ cat arithmetic.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">#!/bin/bash</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$1=$1&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$2=$2&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"><br />
</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">let add=$1+$2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">let sub=$1-$2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">let mul=$1*$2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">let div=$1/$2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;Addition=$add\nSubtraction=$sub\nMultiplication=$mul\nDivision=$div\n&#8221;</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">Next, execute the arithmetic.sh with proper parameters as shown below.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ ./arithmetic.sh 12 10</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$1=12</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$2=10</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Addition=22</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Subtraction=2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Multiplication=120</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Division=1</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">In the above output $1 has the value 12, and $2 has 10.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">Shell built-in ‘let’ allows arithmetic operation to be performed on shell variables. The above script does the arithmetic operations such as addition, subtraction, multiplication and division on the given parameters.</span></p>
<p class="MsoNormal" style="line-height: normal;"><strong><em><span style="text-decoration: underline;"><span style="font-size: 9pt;">Set / Unset Bash Positional Parameters</span></span></em></strong></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">The built in set command is used to set and unset the positional parameter.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">First, create the positional.sh shell script as shown below.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ cat positional.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">#!/bin/bash</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"># From command line</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;Basename=$0&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$1=$1&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$2=$2&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$3=$3&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"># From Set builtin</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">set First Second Third</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$1=$1&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$2=$2&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$3=$3&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"># Store positional parameters with -(hyphen)</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">set &#8211; -f -s -t</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$1=$1&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$2=$2&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$3=$3&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"># Unset positional parameter</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">set &#8212;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$1=$1&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$2=$2&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$3=$3&#8221;</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">The above script prints the command line arguments first, then set command sets the positional parameter explicitly. Set with the – refers end of options, all following arguments are positional parameter even they can begin with ‘-’. Set with ‘–’ without any other arguments unset all the positional parameters.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">Next, execute the positional.sh as shown below.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ ./positional.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Basename=positional.sh</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$1=12</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$2=10</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$3=</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$1=First</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$2=Second</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$3=Third</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$1=-f</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$2=-s</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$3=-t</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$1=</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$2=</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$3=<br />
</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="line-height: normal;"><strong><em><span style="text-decoration: underline;"><span style="font-size: 9pt;">Use Bash $* and $@ to Expand Positional Parameters</span></span></em></strong></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">This example shows the value available in <strong>$*</strong> and <strong>$@</strong>.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">First, create the expan.sh as shown below.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ cat expan.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">#!/bin/bash</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">export IFS=&#8217;-&#8216;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">cnt=1</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"># Printing the data available in $*</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo &#8220;Values of \&#8221;\$*\&#8221;:&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">for arg in &#8220;$*&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">do</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> echo &#8220;Arg #$cnt= $arg&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> let &#8220;cnt+=1&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">done</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">cnt=1</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"># Printing the data available in $@</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo &#8220;Values of \&#8221;\$@\&#8221;:&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">for arg in &#8220;$@&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">do</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> echo &#8220;Arg #$cnt= $arg&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> let &#8220;cnt+=1&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">done</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">Next, execute the expan.sh as shown below to see how $* and $@ works.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ ./expan.sh &#8220;This is&#8221; 2 3</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Values of &#8220;$*&#8221;:</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Arg #1= This is-2-3</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Values of &#8220;$@&#8221;:</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Arg #1= This is</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Arg #2= 2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Arg #3= 3</span></em></p>
<p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Symbol;">· </span><span style="font-size: 9pt;">The above script exported the value of IFS (Internal Field Separator) with the ‘-’.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Symbol;">· </span><span style="font-size: 9pt;">There are three parameter passed to the script expan.sh $1=”This is”,$2=”2″ and $3=”3″.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Symbol;">· </span><span style="font-size: 9pt;">When printing the each value of special parameter “$*”, it gives only one value which is the whole positional parameter delimited by IFS.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Symbol;">· </span><span style="font-size: 9pt;">Whereas “$@” gives you each parameter as a separate word.</span></p>
<p class="MsoNormal" style="line-height: normal;"><strong><em><span style="text-decoration: underline;"><span style="font-size: 9pt;">Use $# to Count Positional Parameters</span></span></em></strong></p>
<p class="MsoNormal" style="line-height: normal;"><strong><span style="font-size: 9pt;">$#</span></strong><span style="font-size: 9pt;"> is the special parameter in bash which gives you the number of positional parameter in decimal.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">First, create the arithmetic.sh as shown below.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ cat arithmetic.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">#!/bin/bash</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">if [ $# -lt 2 ]</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">then</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> echo &#8220;Usage: $0 arg1 arg2&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> exit</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">fi</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$1=$1&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;\$2=$2&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">let add=$1+$2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">let sub=$1-$2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">let mul=$1*$2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">let div=$1/$2</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;Addition=$add\nSubtraction=$sub\nMultiplication=$mul\nDivision=$div\n&#8221;</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">If the number of positional parameters is less than 2, it will throw the usage information as shown below,</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ ./arithemetic.sh 10</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Usage: ./arithemetic.sh arg1 arg2</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><strong><em><span style="text-decoration: underline;"><span style="font-size: 9pt;">Process related Parameters – $$ and $!</span></span></em></strong></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">The special parameter <strong>$$</strong> will give the process ID of the shell. <strong>$!</strong> gives you the process id of the most recently executed background process.</span></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">The following script prints the process id of the shell and last execute background process ID.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ cat proc.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">#!/bin/bash</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;Process ID=$$&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">sleep 1000 &amp;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;Background Process ID=$!&#8221;</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">Now, execute the above script, and check the process id which its printing.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ ./proc.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Process ID=9502</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Background Process ID=9503</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$ ps</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> PID TTY TIME CMD</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> 5970 pts/1 00:00:00 bash</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> 9503 pts/1 00:00:00 sleep</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> 9504 pts/1 00:00:00 ps</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">$</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><strong><em><span style="text-decoration: underline;"><span style="font-size: 9pt;">Other Bash Special Parameters – $?, $-, $_</span></span></em></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Symbol;">· </span><strong><span style="font-size: 9pt;">$?</span></strong><span style="font-size: 9pt;"> Gives the exit status of the most recently executed command.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Symbol;">· </span><strong><span style="font-size: 9pt;">$-</span></strong><span style="font-size: 9pt;"> Options set using set builtin command</span></p>
<p class="MsoNormal" style="margin-left: 0.25in; text-indent: -0.25in; line-height: normal;"><span style="font-size: 10pt; font-family: Symbol;">· </span><strong><span style="font-size: 9pt;">$_</span></strong><span style="font-size: 9pt;"> Gives the last argument to the previous command. At the shell startup, it gives the absolute filename of the shell script being executed.</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ cat others.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">#!/bin/bash</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;$_&#8221;; ## Absolute name of the file which is being executed</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">/usr/local/bin/dbhome # execute the command.</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">#check the exit status of dbhome</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">if [ &#8220;$?&#8221; -ne &#8220;0&#8221; ]; then</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;"> echo &#8220;Sorry, Command execution failed !&#8221;</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">fi</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e &#8220;$-&#8220;; #Set options &#8211; hB</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">echo -e $_ # Last argument of the previous command.</span></em></p>
<p class="MsoNormal" style="line-height: normal;"><span style="font-size: 9pt;">In the above script, the last echo statement “echo -e $_” ($ underscore) also prints hB which is the value of last argument of the previous command. So $_ will give the value after expansion</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><strong><em><span style="font-size: 9pt;">$ ./others.sh</span></em></strong></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">./others.sh</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">/home/oracle</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">Sorry, Command execution failed !</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">hB</span></em></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-size: 9pt;">hB</span></em></p>
<p class="MsoNormal">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;">
<p class="MsoNormal">
<p>The post <a href="https://www.scmgalaxy.com/tutorials/shell-script-parameters/">Understand Shell Script Parameters &#8211; Reference</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/shell-script-parameters/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
