Bash Built-In Variables: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
Line 7: Line 7:
==IFS==
==IFS==


==List Separator==
<blockquote style="background-color: Gold; border: solid thin Goldenrod;">
 
:'''Note''' you must set IFS back to " " after setting it to something else, so the basic shell function work as expected. This is done with IFS=" ".<br>
The default list separator is space. That can be changed by setting the value of the <tt>IFS</tt> variable before executing <tt>set</tt>.
</blockquote>


Example:
Also see:


<pre>
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
arg="a,b,c"
:[[bash set#List_Separator|bash <tt>set</tt> List Separator]]
IFS=","
set ${arg}
</pre>
 
will identically assign "a", "b", "c" to positional parameters $1, $2 and $3.
 
<blockquote style="background-color: Gold; border: solid thin Goldenrod;">
:'''Note''' you must set IFS back to " " after setting it to something else, so the basic shell function work as expected. This is done with IFS=" ".<br>
</blockquote>
</blockquote>

Revision as of 23:36, 29 February 2016

Internal

Standard Environment Variables

IFS

Note you must set IFS back to " " after setting it to something else, so the basic shell function work as expected. This is done with IFS=" ".

Also see:

bash set List Separator