<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changing IFS within a shell script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851316#M100798</link>
    <description>Ohters will tell you better trick and solution, mine is a workaround...&lt;BR /&gt;&lt;BR /&gt;at the beginning of the script&lt;BR /&gt;&lt;BR /&gt;SAVE_IFS=$IFS&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;work as needed&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;at the end of the script.&lt;BR /&gt;&lt;BR /&gt;IFS=${SAVE_IFS}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 20 Nov 2003 03:59:52 GMT</pubDate>
    <dc:creator>Massimo Bianchi</dc:creator>
    <dc:date>2003-11-20T03:59:52Z</dc:date>
    <item>
      <title>Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851314#M100796</link>
      <description>&lt;P&gt;Hi !&lt;BR /&gt;&lt;BR /&gt;I need to access different column data files within the same shell script, but they use different field separators so that before doing&lt;BR /&gt;&lt;BR /&gt;while read A B C&lt;BR /&gt;do&lt;BR /&gt;...&lt;BR /&gt;done &amp;lt; file.dat&lt;BR /&gt;&lt;BR /&gt;I need to setup IFS to ";" for instance.&lt;BR /&gt;&lt;BR /&gt;Once done that I would like to reset IFS to the original value (tabs, spaces) but doing&lt;BR /&gt;&lt;BR /&gt;IFS="", or IFS=" " doesn't work like at the beginning.&lt;BR /&gt;&lt;BR /&gt;How can I do that ?&lt;BR /&gt;&lt;BR /&gt;At the beginning running&lt;BR /&gt;&lt;BR /&gt;echo $IFS"+"&lt;BR /&gt;&lt;BR /&gt;gives me back &lt;BR /&gt;&lt;BR /&gt;$+&lt;BR /&gt;&lt;BR /&gt;so that I thought the default value was "", but it's not that easy ... sigh.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance !&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Mike&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. This thread has been moved from HP-UX &amp;gt;&amp;nbsp;General to HP-UX &amp;gt; languages - HP Forums moderator&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2012 05:01:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851314#M100796</guid>
      <dc:creator>Michele (Mike) Alberton</dc:creator>
      <dc:date>2012-10-22T05:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851315#M100797</link>
      <description>Hi,&lt;BR /&gt;have you tried the simple approach; save the original value at the very beginning of your script:&lt;BR /&gt;SAVE_IFS="$IFS"&lt;BR /&gt;and then restore the value later...&lt;BR /&gt;&lt;BR /&gt;IFS="$SAVE_IFS"&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Thu, 20 Nov 2003 03:59:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851315#M100797</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-11-20T03:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851316#M100798</link>
      <description>Ohters will tell you better trick and solution, mine is a workaround...&lt;BR /&gt;&lt;BR /&gt;at the beginning of the script&lt;BR /&gt;&lt;BR /&gt;SAVE_IFS=$IFS&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;work as needed&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;at the end of the script.&lt;BR /&gt;&lt;BR /&gt;IFS=${SAVE_IFS}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Nov 2003 03:59:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851316#M100798</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-11-20T03:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851317#M100799</link>
      <description>The default value for IFS is a newline, not a null. In any posix shell I get;&lt;BR /&gt;&lt;BR /&gt;echo "A${IFS}B"&lt;BR /&gt;A&lt;BR /&gt;B&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Nov 2003 04:04:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851317#M100799</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2003-11-20T04:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851318#M100800</link>
      <description>That's why I love this FORUM !&lt;BR /&gt;&lt;BR /&gt;Simply great, thanks to both, well earned !&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Mike</description>
      <pubDate>Thu, 20 Nov 2003 04:05:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851318#M100800</guid>
      <dc:creator>Michele (Mike) Alberton</dc:creator>
      <dc:date>2003-11-20T04:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851319#M100801</link>
      <description>You could also do it like this:&lt;BR /&gt;&lt;BR /&gt;(&lt;BR /&gt;IFS="${IFS}|"&lt;BR /&gt;while read A B C&lt;BR /&gt;do&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;done&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;The parenthesis set-up a sub-environment.  You can even cd(1) within the parenthesis and outside them go back to where you were w/o having to record where you came from.&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;-dlt-</description>
      <pubDate>Fri, 21 Nov 2003 14:01:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851319#M100801</guid>
      <dc:creator>David Totsch</dc:creator>
      <dc:date>2003-11-21T14:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851320#M100802</link>
      <description>Thanks David,&lt;BR /&gt;&lt;BR /&gt;I implemented the backup and restore approach, but definitely this looks very elegant.&lt;BR /&gt;I'm still wondering if there's any chance to reset the value of IFS, without the need of restoring it through an external var.Ã¹&lt;BR /&gt;I odumped the value and it really looks a NULL, but it is not...&lt;BR /&gt;&lt;BR /&gt;Again, thanks !&lt;BR /&gt;&lt;BR /&gt;Mi</description>
      <pubDate>Fri, 21 Nov 2003 14:09:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851320#M100802</guid>
      <dc:creator>Michele (Mike) Alberton</dc:creator>
      <dc:date>2003-11-21T14:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851321#M100803</link>
      <description>Hi Mike,&lt;BR /&gt;&lt;BR /&gt;thats just, what Davids approach does.&lt;BR /&gt;() creates a subenvironment, which ceases to exist after ), so you can do to IFS all you want and no need to restore it.&lt;BR /&gt;&lt;BR /&gt;right Dave?&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Fri, 21 Nov 2003 14:37:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851321#M100803</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-21T14:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851322#M100804</link>
      <description>the default value of IFS is the space character, the tab character, and the newline&lt;BR /&gt;IFS=" \t\n"&lt;BR /&gt;&lt;BR /&gt;do an print $IFS | vis -n to see the characters</description>
      <pubDate>Fri, 21 Nov 2003 14:44:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851322#M100804</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-11-21T14:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Changing IFS within a shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851323#M100805</link>
      <description>Usage of parenthesis to group the set of instructions using the new IFS worked ok.&lt;BR /&gt;Thanks to all those who helped me in this</description>
      <pubDate>Fri, 27 Jan 2006 13:21:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/changing-ifs-within-a-shell-script/m-p/4851323#M100805</guid>
      <dc:creator>Michele (Mike) Alberton</dc:creator>
      <dc:date>2006-01-27T13:21:22Z</dc:date>
    </item>
  </channel>
</rss>

