<?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>Linux Ask! &#187; Programming</title>
	<atom:link href="http://www.linuxask.com/topics/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxask.com</link>
	<description>Linux Ask! is a Q &#38; A web site specific for Linux related questions such as how to use common Linux commands.</description>
	<lastBuildDate>Tue, 05 May 2015 07:15:40 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>How to get the current running Java processes with full argument</title>
		<link>http://www.linuxask.com/questions/how-to-get-the-current-running-java-processes-with-full-argument</link>
		<comments>http://www.linuxask.com/questions/how-to-get-the-current-running-java-processes-with-full-argument#comments</comments>
		<pubDate>Sun, 26 Oct 2014 17:51:06 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4458</guid>
		<description><![CDATA[How to get the current running Java processes with full argument Answer: To do so, use the command: #jps -mlvV<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/find-the-number-of-running-processes-on-your-system" rel="bookmark" title="Find the number of running processes on your system">Find the number of running processes on your system </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-disable-ipv6-support-in-a-java-program" rel="bookmark" title="How to disable IPv6 support in a Java program">How to disable IPv6 support in a Java program </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-alter-the-priority-of-running-processes" rel="bookmark" title="How to alter the priority of running processes">How to alter the priority of running processes </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to get the current running Java processes with full argument</p>
<p><strong>Answer:</strong></p>
<p>To do so, use the command:</p>
<p><code>#jps -mlvV</code></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/find-the-number-of-running-processes-on-your-system" rel="bookmark" title="Find the number of running processes on your system">Find the number of running processes on your system </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-disable-ipv6-support-in-a-java-program" rel="bookmark" title="How to disable IPv6 support in a Java program">How to disable IPv6 support in a Java program </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-alter-the-priority-of-running-processes" rel="bookmark" title="How to alter the priority of running processes">How to alter the priority of running processes </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-get-the-current-running-java-processes-with-full-argument/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trap bash exit signal</title>
		<link>http://www.linuxask.com/questions/trap-bash-exit-signal</link>
		<comments>http://www.linuxask.com/questions/trap-bash-exit-signal#comments</comments>
		<pubDate>Wed, 02 Jul 2014 04:20:55 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4427</guid>
		<description><![CDATA[Trap bash exit signal Answer: To trap your script before exit, you can use the trap in bash, e.g. #!/bin/bash set -eu function bye { echo "Good bye" } trap bye EXIT sleep 1000 # Quit the script by pressing Ctrl+C<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-execute-a-command-repeatedly-using-bash" rel="bookmark" title="How to execute a command repeatedly using bash">How to execute a command repeatedly using bash </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-ignore-error-in-bash-script" rel="bookmark" title="How to ignore error in Bash script">How to ignore error in Bash script </a></li>
<li><a href="http://www.linuxask.com/questions/difference-between-die-and-exit-in-perl" rel="bookmark" title="Difference between die and exit in Perl?">Difference between die and exit in Perl? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Trap bash exit signal</p>
<p><strong>Answer:</strong></p>
<p>To trap your script before exit, you can use the <strong>trap</strong> in bash, e.g.</p>
<pre><code>#!/bin/bash

set -eu

function bye {
  echo "Good bye"
}

trap bye EXIT
sleep 1000 
# Quit the script by pressing Ctrl+C
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-execute-a-command-repeatedly-using-bash" rel="bookmark" title="How to execute a command repeatedly using bash">How to execute a command repeatedly using bash </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-ignore-error-in-bash-script" rel="bookmark" title="How to ignore error in Bash script">How to ignore error in Bash script </a></li>
<li><a href="http://www.linuxask.com/questions/difference-between-die-and-exit-in-perl" rel="bookmark" title="Difference between die and exit in Perl?">Difference between die and exit in Perl? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/trap-bash-exit-signal/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing more robust shell script</title>
		<link>http://www.linuxask.com/questions/writing-more-robust-shell-script</link>
		<comments>http://www.linuxask.com/questions/writing-more-robust-shell-script#comments</comments>
		<pubDate>Sat, 28 Jun 2014 04:10:58 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Advanced Linux]]></category>
		<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4425</guid>
		<description><![CDATA[Writing more robust shell script Answer: You should always start your bash shell script with the line set -eu The meaning is: -e: cause the script to exit if an error -u: cause the script to exit if any variable is not set<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-get-the-pid-in-current-bash-shell-script" rel="bookmark" title="How to get the PID in current bash shell script">How to get the PID in current bash shell script </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-ignore-error-in-bash-script" rel="bookmark" title="How to ignore error in Bash script">How to ignore error in Bash script </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-make-shell-script-run-in-low-priority" rel="bookmark" title="How to make shell script run in low priority">How to make shell script run in low priority </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Writing more robust shell script</p>
<p><strong>Answer:</strong></p>
<p>You should always start your bash shell script with the line <code>set -eu</code></p>
<p>The meaning is:</p>
<ol>
<li>-e: cause the script to exit if an error</li>
<li>-u: cause the script to exit if any variable is not set</li>
</ol>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-get-the-pid-in-current-bash-shell-script" rel="bookmark" title="How to get the PID in current bash shell script">How to get the PID in current bash shell script </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-ignore-error-in-bash-script" rel="bookmark" title="How to ignore error in Bash script">How to ignore error in Bash script </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-make-shell-script-run-in-low-priority" rel="bookmark" title="How to make shell script run in low priority">How to make shell script run in low priority </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/writing-more-robust-shell-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Perl to split string instead of awk</title>
		<link>http://www.linuxask.com/questions/use-perl-to-split-string-instead-of-awk</link>
		<comments>http://www.linuxask.com/questions/use-perl-to-split-string-instead-of-awk#comments</comments>
		<pubDate>Thu, 29 May 2014 08:04:28 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Advanced Linux]]></category>
		<category><![CDATA[Commands]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4402</guid>
		<description><![CDATA[Use Perl to split string instead of awk Answer: If you know Perl well, there is no need to use awk to do string processing such as string splitting, it is easy with Perl also, e.g. # echo "foo,bar,k3" &#124; perl -F',' -lane 'print $F[1]' bar<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/split-a-string-into-array-in-perl" rel="bookmark" title="Split a string into array in Perl">Split a string into array in Perl </a></li>
<li><a href="http://www.linuxask.com/questions/trim-a-string-using-perl" rel="bookmark" title="Trim a string using Perl">Trim a string using Perl </a></li>
<li><a href="http://www.linuxask.com/questions/remove-the-last-character-of-a-string-in-perl" rel="bookmark" title="Remove the last character of a string in Perl">Remove the last character of a string in Perl </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Use Perl to split string instead of awk</p>
<p><strong>Answer:</strong></p>
<p>If you know Perl well, there is no need to use awk to do string processing such as string splitting, it is easy with Perl also, e.g.</p>
<pre><code># echo "foo,bar,k3"  | perl -F',' -lane 'print $F[1]'
bar
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/split-a-string-into-array-in-perl" rel="bookmark" title="Split a string into array in Perl">Split a string into array in Perl </a></li>
<li><a href="http://www.linuxask.com/questions/trim-a-string-using-perl" rel="bookmark" title="Trim a string using Perl">Trim a string using Perl </a></li>
<li><a href="http://www.linuxask.com/questions/remove-the-last-character-of-a-string-in-perl" rel="bookmark" title="Remove the last character of a string in Perl">Remove the last character of a string in Perl </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/use-perl-to-split-string-instead-of-awk/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to assign a raw string in Python</title>
		<link>http://www.linuxask.com/questions/how-to-assign-a-raw-string-in-python</link>
		<comments>http://www.linuxask.com/questions/how-to-assign-a-raw-string-in-python#comments</comments>
		<pubDate>Sat, 26 Apr 2014 08:00:32 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4394</guid>
		<description><![CDATA[How to assign a raw string in Python Answer: In Python, if you want to assign a raw string without any character escape, you can use the following: s = r'\\foo\\\bar' print s<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python" rel="bookmark" title="How to modify a single character in a string in Python?">How to modify a single character in a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python" rel="bookmark" title="How do I convert a number to a string in Python?">How do I convert a number to a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-python" rel="bookmark" title="Multi-line string in Python">Multi-line string in Python </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to assign a raw string in Python</p>
<p><strong>Answer:</strong></p>
<p>In Python, if you want to assign a raw string without any character escape, you can use the following:</p>
<pre><code>s = r'\\foo\\\bar'
print s</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-modify-a-single-character-in-a-string-in-python" rel="bookmark" title="How to modify a single character in a string in Python?">How to modify a single character in a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/how-do-i-convert-a-number-to-a-string-in-python" rel="bookmark" title="How do I convert a number to a string in Python?">How do I convert a number to a string in Python? </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-python" rel="bookmark" title="Multi-line string in Python">Multi-line string in Python </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-assign-a-raw-string-in-python/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to sum a particular column of a CSV file with awk</title>
		<link>http://www.linuxask.com/questions/how-to-sum-a-particular-column-of-a-csv-file-with-awk</link>
		<comments>http://www.linuxask.com/questions/how-to-sum-a-particular-column-of-a-csv-file-with-awk#comments</comments>
		<pubDate>Mon, 29 Jul 2013 09:16:07 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[awk]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4284</guid>
		<description><![CDATA[How to sum a particular column of a CSV file with awk Answer: Assume you have a CSV file like the following (only contain number) 1,2,3 2,3,4 3,4,5 ... How do you sum the nth column of this file? It is easy with the use of awk e.g. Assume you want to sum the 2nd <a href='http://www.linuxask.com/questions/how-to-sum-a-particular-column-of-a-csv-file-with-awk' class='excerpt-more'>[...]</a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/extract-column-data-using-awk" rel="bookmark" title="Extract column data using awk">Extract column data using awk </a></li>
<li><a href="http://www.linuxask.com/questions/print-a-particular-column-data-using-awk" rel="bookmark" title="Print a particular column data using awk">Print a particular column data using awk </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-sort-a-file-by-n-column" rel="bookmark" title="How to sort a file by n-column">How to sort a file by n-column </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to sum a particular column of a CSV file with awk</p>
<p><strong>Answer:</strong></p>
<p>Assume you have a CSV file like the following (only contain number)</p>
<pre>1,2,3
2,3,4
3,4,5
...</pre>
<p>How do you sum the nth column of this file? It is easy with the use of <strong>awk</strong></p>
<p>e.g. Assume you want to sum the 2nd column:</p>
<p><code># awk -F "," '{ sum += $2 } END { print sum }' test.txt </code></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/extract-column-data-using-awk" rel="bookmark" title="Extract column data using awk">Extract column data using awk </a></li>
<li><a href="http://www.linuxask.com/questions/print-a-particular-column-data-using-awk" rel="bookmark" title="Print a particular column data using awk">Print a particular column data using awk </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-sort-a-file-by-n-column" rel="bookmark" title="How to sort a file by n-column">How to sort a file by n-column </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-sum-a-particular-column-of-a-csv-file-with-awk/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File content redirection without using cat</title>
		<link>http://www.linuxask.com/questions/file-content-redirection-without-using-cat</link>
		<comments>http://www.linuxask.com/questions/file-content-redirection-without-using-cat#comments</comments>
		<pubDate>Thu, 25 Jul 2013 09:11:24 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Commands]]></category>
		<category><![CDATA[cat]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4281</guid>
		<description><![CDATA[File content redirection without using cat Answer: It is not uncommon that people have abused the command `cat` for many purpose, e.g. file I/O redirection cat data.txt &#124; sed 's/foo/bar/s' You can avoid the cat command by the following commands: data.txt < sed 's/foo/bar/s' sed 's/foo/bar/s' < data.txt Both directions are okay. In fact, when <a href='http://www.linuxask.com/questions/file-content-redirection-without-using-cat' class='excerpt-more'>[...]</a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/synchronize-data-on-disk-with-memory" rel="bookmark" title="Synchronize data on disk with memory">Synchronize data on disk with memory </a></li>
<li><a href="http://www.linuxask.com/questions/show-the-content-of-gzipped-text-file" rel="bookmark" title="Show the content of gzipped text file">Show the content of gzipped text file </a></li>
<li><a href="http://www.linuxask.com/questions/permission-denied-when-doing-redirection-with-sudo" rel="bookmark" title="Permission denied when doing redirection with sudo">Permission denied when doing redirection with sudo </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>File content redirection without using cat</p>
<p><strong>Answer:</strong></p>
<p>It is not uncommon that people have abused the command `<strong>cat</strong>` for many purpose, e.g. file I/O redirection</p>
<pre><code>cat data.txt | sed 's/foo/bar/s'</code></pre>
<p>You can avoid the <strong>cat</strong> command by the following commands:</p>
<pre><code>data.txt < sed 's/foo/bar/s'
sed 's/foo/bar/s' < data.txt</code></pre>
<p>Both directions are okay.</p>
<p>In fact, when you better understand the usage of some commands, you might find out that redirection is completely not needed.</p>
<p>e.g.</p>
<p><code>sed 's/foo/bar/s' data.txt</code></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/synchronize-data-on-disk-with-memory" rel="bookmark" title="Synchronize data on disk with memory">Synchronize data on disk with memory </a></li>
<li><a href="http://www.linuxask.com/questions/show-the-content-of-gzipped-text-file" rel="bookmark" title="Show the content of gzipped text file">Show the content of gzipped text file </a></li>
<li><a href="http://www.linuxask.com/questions/permission-denied-when-doing-redirection-with-sudo" rel="bookmark" title="Permission denied when doing redirection with sudo">Permission denied when doing redirection with sudo </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/file-content-redirection-without-using-cat/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to echo single quote in bash shell</title>
		<link>http://www.linuxask.com/questions/how-to-echo-single-quote-in-bash-shell</link>
		<comments>http://www.linuxask.com/questions/how-to-echo-single-quote-in-bash-shell#comments</comments>
		<pubDate>Tue, 23 Apr 2013 05:24:53 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Commands]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4221</guid>
		<description><![CDATA[How to echo single quote in bash shell Answer: To echo single quote (using single quote only), you can try # echo foo foo # echo \'''foo 'foo<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/simple-for-loop-in-bash-shell" rel="bookmark" title="Simple for loop in Bash shell">Simple for loop in Bash shell </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-get-the-pid-in-current-bash-shell-script" rel="bookmark" title="How to get the PID in current bash shell script">How to get the PID in current bash shell script </a></li>
<li><a href="http://www.linuxask.com/questions/check-if-a-file-exist-in-bash-shell" rel="bookmark" title="Check if a file exist in Bash Shell">Check if a file exist in Bash Shell </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to echo single quote in bash shell</p>
<p><strong>Answer:</strong></p>
<p>To echo single quote (using single quote only), you can try</p>
<pre><code># echo foo
foo
# echo \'''foo
'foo
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/simple-for-loop-in-bash-shell" rel="bookmark" title="Simple for loop in Bash shell">Simple for loop in Bash shell </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-get-the-pid-in-current-bash-shell-script" rel="bookmark" title="How to get the PID in current bash shell script">How to get the PID in current bash shell script </a></li>
<li><a href="http://www.linuxask.com/questions/check-if-a-file-exist-in-bash-shell" rel="bookmark" title="Check if a file exist in Bash Shell">Check if a file exist in Bash Shell </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-echo-single-quote-in-bash-shell/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Constant in Ruby</title>
		<link>http://www.linuxask.com/questions/constant-in-ruby</link>
		<comments>http://www.linuxask.com/questions/constant-in-ruby#comments</comments>
		<pubDate>Thu, 04 Apr 2013 04:41:36 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4212</guid>
		<description><![CDATA[Constant in Ruby Answer: In Ruby, a class constant has a name starting with an uppercase character, e.g. Foo = 'bar' puts Foo Where you try to re-define the constant, a warning message will be shown, e.g. Foo = 'bar' Foo = '123' (irb):18: warning: already initialized constant Foo<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/define-a-constant-in-php" rel="bookmark" title="Define a constant in PHP">Define a constant in PHP </a></li>
<li><a href="http://www.linuxask.com/questions/install-ruby-in-ubuntu" rel="bookmark" title="Install Ruby in Ubuntu">Install Ruby in Ubuntu </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-ruby" rel="bookmark" title="Multi-line string in Ruby">Multi-line string in Ruby </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Constant in Ruby</p>
<p><strong>Answer:</strong></p>
<p>In Ruby, a class constant has a name starting with an uppercase character, e.g.</p>
<pre><code>Foo = 'bar'
puts Foo</code></pre>
<p>Where you try to re-define the constant, a warning message will be shown, e.g.</p>
<pre><code>Foo = 'bar'
Foo = '123'

(irb):18: warning: already initialized constant Foo</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/define-a-constant-in-php" rel="bookmark" title="Define a constant in PHP">Define a constant in PHP </a></li>
<li><a href="http://www.linuxask.com/questions/install-ruby-in-ubuntu" rel="bookmark" title="Install Ruby in Ubuntu">Install Ruby in Ubuntu </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-ruby" rel="bookmark" title="Multi-line string in Ruby">Multi-line string in Ruby </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/constant-in-ruby/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Global and Local variable in Ruby</title>
		<link>http://www.linuxask.com/questions/global-and-local-variable-in-ruby</link>
		<comments>http://www.linuxask.com/questions/global-and-local-variable-in-ruby#comments</comments>
		<pubDate>Fri, 29 Mar 2013 04:40:11 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=4208</guid>
		<description><![CDATA[Global and Local variable in Ruby Answer: In Ruby, global variable has a name beginning with $, e.g. $foo = 'bar' puts $foo In contrast, local variable has a name start with a lower case letter or an underscore character, e.g. foo = 'bar' puts foo<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/constant-in-ruby" rel="bookmark" title="Constant in Ruby">Constant in Ruby </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-ruby" rel="bookmark" title="Multi-line string in Ruby">Multi-line string in Ruby </a></li>
<li><a href="http://www.linuxask.com/questions/install-ruby-in-ubuntu" rel="bookmark" title="Install Ruby in Ubuntu">Install Ruby in Ubuntu </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Global and Local variable in Ruby</p>
<p><strong>Answer:</strong></p>
<p>In Ruby, <strong>global variable </strong> has a name beginning with $, e.g.</p>
<pre><code>$foo = 'bar'
puts $foo</code></pre>
<p>In contrast, <strong>local variable</strong> has a name start with a lower case letter or an underscore character, e.g.</p>
<pre><code>foo = 'bar'
puts foo</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/constant-in-ruby" rel="bookmark" title="Constant in Ruby">Constant in Ruby </a></li>
<li><a href="http://www.linuxask.com/questions/multi-line-string-in-ruby" rel="bookmark" title="Multi-line string in Ruby">Multi-line string in Ruby </a></li>
<li><a href="http://www.linuxask.com/questions/install-ruby-in-ubuntu" rel="bookmark" title="Install Ruby in Ubuntu">Install Ruby in Ubuntu </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/global-and-local-variable-in-ruby/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
