<?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; Bash</title>
	<atom:link href="http://www.linuxask.com/topics/programming/bash/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>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>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>How to ignore error in Bash script</title>
		<link>http://www.linuxask.com/questions/how-to-ignore-error-in-bash-script</link>
		<comments>http://www.linuxask.com/questions/how-to-ignore-error-in-bash-script#comments</comments>
		<pubDate>Fri, 29 Jun 2012 03:15:52 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3844</guid>
		<description><![CDATA[How to ignore error in Bash script Answer: We have learned in the past on how to show the exit status of a given command. But is it possible ignore the error and return normal exit code even the command has failed? Yes, pipe "&#124;&#124; true" to the end of command, e.g. # foo &#124;&#124; <a href='http://www.linuxask.com/questions/how-to-ignore-error-in-bash-script' class='excerpt-more'>[...]</a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-on-a-bash-script" rel="bookmark" title="How to perform syntax check on a bash script?">How to perform syntax check on a bash script? </a></li>
<li><a href="http://www.linuxask.com/questions/writing-more-robust-shell-script" rel="bookmark" title="Writing more robust shell script">Writing more robust shell script </a></li>
<li><a href="http://www.linuxask.com/questions/trap-bash-exit-signal" rel="bookmark" title="Trap bash exit signal">Trap bash exit signal </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to ignore error in Bash script</p>
<p><strong>Answer:</strong></p>
<p>We have learned in the past on how to <strong><a href="http://www.linuxask.com/questions/check-the-exit-status-of-a-command">show the exit status</a></strong> of a given command.</p>
<p>But is it possible ignore the error and return normal exit code even the command has failed?</p>
<p>Yes, pipe "<strong>|| true</strong>" to the end of command, e.g.</p>
<pre><code># foo || true
-bash: foo: command not found
# echo $?
0</code></pre>
<p>As you can see even the command <strong>foo</strong> was not found, our last exit code is still zero.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-on-a-bash-script" rel="bookmark" title="How to perform syntax check on a bash script?">How to perform syntax check on a bash script? </a></li>
<li><a href="http://www.linuxask.com/questions/writing-more-robust-shell-script" rel="bookmark" title="Writing more robust shell script">Writing more robust shell script </a></li>
<li><a href="http://www.linuxask.com/questions/trap-bash-exit-signal" rel="bookmark" title="Trap bash exit signal">Trap bash exit signal </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-ignore-error-in-bash-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Split on specific characters on Bash Script&#8217;s for loop</title>
		<link>http://www.linuxask.com/questions/split-on-specific-characters-on-bash-scripts-for-loop</link>
		<comments>http://www.linuxask.com/questions/split-on-specific-characters-on-bash-scripts-for-loop#comments</comments>
		<pubDate>Mon, 20 Feb 2012 15:21:01 +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=3713</guid>
		<description><![CDATA[Split on specific characters on Bash Script's for loop Answer: If you want to Bash script's for loop to split on non white-space characters, you can change the IFS, e.g. #!/bin/bash IFS='-' list="a-b-c-d-e" for c in $list; do echo $c done The above script will split on the character '-' E.g. # ./test.sh a b <a href='http://www.linuxask.com/questions/split-on-specific-characters-on-bash-scripts-for-loop' class='excerpt-more'>[...]</a><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-echo-a-tab-in-bash" rel="bookmark" title="How to echo a tab in bash?">How to echo a tab in bash? </a></li>
<li><a href="http://www.linuxask.com/questions/swap-last-two-characters-in-bash" rel="bookmark" title="Swap last two characters in Bash">Swap last two characters in Bash </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Split on specific characters on Bash Script's for loop</p>
<p><strong>Answer:</strong></p>
<p>If you want to Bash script's for loop to split on non white-space characters, you can change the <strong>IFS</strong>, e.g.</p>
<pre><code>#!/bin/bash
IFS='-'

list="a-b-c-d-e"

for c in $list; do
    echo $c
done</code></pre>
<p>The above script will split on the character '<strong>-</strong>'</p>
<p>E.g.</p>
<pre><code># ./test.sh

a
b
c
d
e
</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-echo-a-tab-in-bash" rel="bookmark" title="How to echo a tab in bash?">How to echo a tab in bash? </a></li>
<li><a href="http://www.linuxask.com/questions/swap-last-two-characters-in-bash" rel="bookmark" title="Swap last two characters in Bash">Swap last two characters in Bash </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/split-on-specific-characters-on-bash-scripts-for-loop/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check if a file exist in Bash Shell</title>
		<link>http://www.linuxask.com/questions/check-if-a-file-exist-in-bash-shell</link>
		<comments>http://www.linuxask.com/questions/check-if-a-file-exist-in-bash-shell#comments</comments>
		<pubDate>Tue, 23 Aug 2011 13:44:55 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3405</guid>
		<description><![CDATA[Check if a file exist in Bash Shell Answer: The following script demonstrates how to check if a file exist, using shell (Bash) script #!/bin/bash if [ -e test.txt ] then echo 'The file exists.' else echo 'The file does not exist.' fi<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-on-a-bash-script" rel="bookmark" title="How to perform syntax check on a bash script?">How to perform syntax check on a bash script? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-check-the-bash-shell-version" rel="bookmark" title="How to check the bash shell version">How to check the bash shell version </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>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Check if a file exist in Bash Shell</p>
<p><strong>Answer:</strong></p>
<p>The following script demonstrates how to check if a file exist, using shell (<strong>Bash</strong>) script </p>
<pre><code>#!/bin/bash

if [ -e test.txt ]
then
  echo 'The file exists.'
else
  echo 'The file does not exist.'
fi
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-perform-syntax-check-on-a-bash-script" rel="bookmark" title="How to perform syntax check on a bash script?">How to perform syntax check on a bash script? </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-check-the-bash-shell-version" rel="bookmark" title="How to check the bash shell version">How to check the bash shell version </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>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/check-if-a-file-exist-in-bash-shell/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to echo string to standard error (stderr)?</title>
		<link>http://www.linuxask.com/questions/how-to-echo-string-to-standard-error-stderr</link>
		<comments>http://www.linuxask.com/questions/how-to-echo-string-to-standard-error-stderr#comments</comments>
		<pubDate>Fri, 03 Jun 2011 14:38:36 +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=3068</guid>
		<description><![CDATA[How to echo string to standard error (stderr)? Answer: To echo string to the standard error (stderr), rather than the standard output (stdout), you can define the following function in your shell (put in your ~/.bashrc file) # function echo2() { echo "$@" 1>&#038;2; } Then you can execute the command like: # echo2 test<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-redirect-error-message-to-a-file" rel="bookmark" title="How to redirect error message to a file">How to redirect error message to a file </a></li>
<li><a href="http://www.linuxask.com/questions/save-program-output-and-error-to-different-files" rel="bookmark" title="Save program output and error to different files">Save program output and error to different files </a></li>
<li><a href="http://www.linuxask.com/questions/printing-the-exclamation-mark-using-echo" rel="bookmark" title="Printing the exclamation mark using echo">Printing the exclamation mark using echo </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>How to echo string to standard error (stderr)?</p>
<p><strong>Answer:</strong></p>
<p>To echo string to the <strong>standard error</strong> (stderr), rather than the <strong>standard output</strong> (stdout), you can define the following function in your shell (put in your  <strong>~/.bashrc</strong> file)</p>
<p><code># function echo2() { echo "$@" 1>&#038;2; }</code></p>
<p>Then you can execute the command like:</p>
<p><code># echo2 test</code></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-redirect-error-message-to-a-file" rel="bookmark" title="How to redirect error message to a file">How to redirect error message to a file </a></li>
<li><a href="http://www.linuxask.com/questions/save-program-output-and-error-to-different-files" rel="bookmark" title="Save program output and error to different files">Save program output and error to different files </a></li>
<li><a href="http://www.linuxask.com/questions/printing-the-exclamation-mark-using-echo" rel="bookmark" title="Printing the exclamation mark using echo">Printing the exclamation mark using echo </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/how-to-echo-string-to-standard-error-stderr/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple for loop in Bash shell</title>
		<link>http://www.linuxask.com/questions/simple-for-loop-in-bash-shell</link>
		<comments>http://www.linuxask.com/questions/simple-for-loop-in-bash-shell#comments</comments>
		<pubDate>Wed, 01 Jun 2011 14:30:12 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=3065</guid>
		<description><![CDATA[Simple for loop in Bash shell Answer: A simple for loop in Bash shell would like the following. You can use it wisely to skip a lot of repetitive tasks. #!/bin/bash for i in {1..10} do echo "I am command No. $i" done<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/split-on-specific-characters-on-bash-scripts-for-loop" rel="bookmark" title="Split on specific characters on Bash Script&#8217;s for loop">Split on specific characters on Bash Script&#8217;s for loop </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>Simple for loop in Bash shell</p>
<p><strong>Answer:</strong></p>
<p>A simple for loop in <strong>Bash </strong>shell would like the following. You can use it wisely to skip a lot of repetitive tasks.</p>
<pre><code>#!/bin/bash

for i in {1..10}
do
   echo "I am command No. $i"
done
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/split-on-specific-characters-on-bash-scripts-for-loop" rel="bookmark" title="Split on specific characters on Bash Script&#8217;s for loop">Split on specific characters on Bash Script&#8217;s for loop </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/simple-for-loop-in-bash-shell/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
