<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>
	Comments on: How To Write and Use Custom Shell Functions and Libraries	</title>
	<atom:link href="https://www.tecmint.com/write-custom-shell-functions-and-libraries-in-linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.tecmint.com/write-custom-shell-functions-and-libraries-in-linux/</link>
	<description>Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks.</description>
	<lastBuildDate>Fri, 10 Feb 2017 09:05:57 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		By: Aaron Kili		</title>
		<link>https://www.tecmint.com/write-custom-shell-functions-and-libraries-in-linux/comment-page-1/#comment-866173</link>

		<dc:creator><![CDATA[Aaron Kili]]></dc:creator>
		<pubDate>Fri, 10 Feb 2017 09:05:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.tecmint.com/?p=24492#comment-866173</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.tecmint.com/write-custom-shell-functions-and-libraries-in-linux/comment-page-1/#comment-866060&quot;&gt;Cloud Consulting Services&lt;/a&gt;.

@Cloud Consulting Services

Really nice, it&#039;s a well organized functions library, many thanks for sharing this with us.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a target="_blank" href="https://www.tecmint.com/write-custom-shell-functions-and-libraries-in-linux/comment-page-1/#comment-866060">Cloud Consulting Services</a>.</p>
<p>@Cloud Consulting Services</p>
<p>Really nice, it&#8217;s a well organized functions library, many thanks for sharing this with us.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Cloud Consulting Services		</title>
		<link>https://www.tecmint.com/write-custom-shell-functions-and-libraries-in-linux/comment-page-1/#comment-866060</link>

		<dc:creator><![CDATA[Cloud Consulting Services]]></dc:creator>
		<pubDate>Thu, 09 Feb 2017 22:48:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.tecmint.com/?p=24492#comment-866060</guid>

					<description><![CDATA[Create a function file called myfunctions.sh:
&lt;code&gt;
#!/bin/bash
# set variables 
declare -r TRUE=0
declare -r FALSE=1
declare -r PASSWD_FILE=/etc/passwd

##################################################################
# Purpose: Converts a string to lower case
# Arguments:
#   $1 -&#062; String to convert to lower case
##################################################################
function to_lower() 
{
    local str=&quot;$@&quot;
    local output     
    output=$(tr &#039;[A-Z]&#039; &#039;[a-z]&#039;&#060;&#060; Message
#   $2 -&#062; Exit status (optional)
##################################################################
function die() 
{
    local m=&quot;$1&quot;	# message
    local e=${2-1}	# default exit status 1
    echo &quot;$m&quot; 
    exit $e
}
##################################################################
# Purpose: Return true if script is executed by the root user
# Arguments: none
# Return: True or False
##################################################################
function is_root() 
{
   [ $(id -u) -eq 0 ] &#038;&#038; return $TRUE &#124;&#124; return $FALSE
}

##################################################################
# Purpose: Return true $user exits in /etc/passwd
# Arguments: $1 (username) -&#062; Username to check in /etc/passwd
# Return: True or False
##################################################################
function is_user_exits() 
{
    local u=&quot;$1&quot;
    grep -q &quot;^${u}&quot; $PASSWD_FILE &#038;&#038; return $TRUE &#124;&#124; return $FALSE
}
&lt;/code&gt;
You can load myfunctions.sh into the current shell environment, enter:
&lt;pre&gt;
$ .myfunctions.sh
OR
$ ./path/to/myfunctions.sh
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Create a function file called myfunctions.sh:<br />
<code><br />
#!/bin/bash<br />
# set variables<br />
declare -r TRUE=0<br />
declare -r FALSE=1<br />
declare -r PASSWD_FILE=/etc/passwd</p>
<p>##################################################################<br />
# Purpose: Converts a string to lower case<br />
# Arguments:<br />
#   $1 -&gt; String to convert to lower case<br />
##################################################################<br />
function to_lower()<br />
{<br />
    local str="$@"<br />
    local output<br />
    output=$(tr '[A-Z]' '[a-z]'&lt;&lt; Message<br />
#   $2 -&gt; Exit status (optional)<br />
##################################################################<br />
function die()<br />
{<br />
    local m="$1"	# message<br />
    local e=${2-1}	# default exit status 1<br />
    echo "$m"<br />
    exit $e<br />
}<br />
##################################################################<br />
# Purpose: Return true if script is executed by the root user<br />
# Arguments: none<br />
# Return: True or False<br />
##################################################################<br />
function is_root()<br />
{<br />
   [ $(id -u) -eq 0 ] &amp;&amp; return $TRUE || return $FALSE<br />
}</p>
<p>##################################################################<br />
# Purpose: Return true $user exits in /etc/passwd<br />
# Arguments: $1 (username) -&gt; Username to check in /etc/passwd<br />
# Return: True or False<br />
##################################################################<br />
function is_user_exits()<br />
{<br />
    local u="$1"<br />
    grep -q "^${u}" $PASSWD_FILE &amp;&amp; return $TRUE || return $FALSE<br />
}<br />
</code><br />
You can load myfunctions.sh into the current shell environment, enter:</p>
<pre>
$ .myfunctions.sh
OR
$ ./path/to/myfunctions.sh
</pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
