<?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: IFS Internal Field Separator in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958705#M100992</link>
    <description>The typical way under the shell would be-&lt;BR /&gt; &lt;BR /&gt;bs=`echo "\010"`&lt;BR /&gt; &lt;BR /&gt;However, since linefeed is a special character used for record seperation within text files, I don't think it's going to work.&lt;BR /&gt; &lt;BR /&gt;If you set IFS to null, then I think you will get the results you are looking for.&lt;BR /&gt; &lt;BR /&gt;perl or awk might be better tools for string processing of a file.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Fri, 10 Feb 2006 11:42:18 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2006-02-10T11:42:18Z</dc:date>
    <item>
      <title>IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958702#M100989</link>
      <description>$#using ksh on 11i, I need to set IFS to a &lt;BR /&gt;$#newline inside a script (to preserve tabs, &lt;BR /&gt;$#leading spaces, whatever).  Interactively, &lt;BR /&gt;$IFS="   #&amp;lt;---- nothing invisible except CR &lt;BR /&gt;&amp;gt;"       #&amp;lt;---- ditto.&lt;BR /&gt;$#this works ok, too, and &lt;BR /&gt;$echo $IFS | od -b&lt;BR /&gt;0000000 012&lt;BR /&gt;0000001&lt;BR /&gt;$#LOOKS almost as I'd expect, though I'm told $#that echo added the 012 (LF) I don't $#believe it - there'd be one on the next $#line too, right?  Anyway, I'd like to do $#this in a script, where you can't see $#what's typed and probably can't remember $#either, so it would be really nice to be &lt;BR /&gt;$#visibly specify exactly what I want, such&lt;BR /&gt;$#as&lt;BR /&gt;$IFS=%012    #or better imho...&lt;BR /&gt;$IFS=$0A&lt;BR /&gt;&lt;BR /&gt;$#I tried &lt;BR /&gt;$IFS=\n&lt;BR /&gt;$#and very curiously get the same result from $echo IFS | od -b&lt;BR /&gt;$# but it sure doesn't work!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TIA</description>
      <pubDate>Thu, 09 Feb 2006 22:12:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958702#M100989</guid>
      <dc:creator>Tracy_33</dc:creator>
      <dc:date>2006-02-09T22:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958703#M100990</link>
      <description>Hi there,&lt;BR /&gt;&lt;BR /&gt;You did not get any suggestion so far, perhaps because forum performance has been spotty (being nice here :-), or perhaps because your topic looks a little confusing (beging nice here :-).&lt;BR /&gt;&lt;BR /&gt;Anyway... &lt;BR /&gt;For a simple discussion on IFS try: Google +shell +ifs [I'm feeling lucky]&lt;BR /&gt;But you seem to know that already.&lt;BR /&gt;&lt;BR /&gt;What problem are you really trying to solve?&lt;BR /&gt;As much as I like reduced, simplyfied examples you may have oversimplyfied and lost the point in your description.&lt;BR /&gt;There may be better tools (awk, perl,...) that avoid the word breaks.&lt;BR /&gt;&lt;BR /&gt;Maybe, just mabye, your problem is solved by just assigning IFS to nothing?&lt;BR /&gt;&lt;BR /&gt;Example (similar to that liverfile example):&lt;BR /&gt;&lt;BR /&gt;# line="learn unix at livefire labs"&lt;BR /&gt;# for i in $line&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; echo $i&lt;BR /&gt;&amp;gt; done&lt;BR /&gt;learn&lt;BR /&gt;unix&lt;BR /&gt;at&lt;BR /&gt;livefire&lt;BR /&gt;labs&lt;BR /&gt;# IFS=&lt;BR /&gt;# for i in $line&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; echo $i&lt;BR /&gt;&amp;gt; done&lt;BR /&gt;learn unix at livefire labs&lt;BR /&gt;# &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;KISS!&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Feb 2006 11:22:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958703#M100990</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-10T11:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958704#M100991</link>
      <description>OK, a little simpler:&lt;BR /&gt;&lt;BR /&gt;Is there an unambiguous way to express control characters to the Posix shell?  &lt;BR /&gt;&lt;BR /&gt;I'd like something like&lt;BR /&gt;&lt;BR /&gt;IFS=%012    # Octal 012, a LineFeed char.&lt;BR /&gt;IFS=$0A     # Hex 0A, same character.&lt;BR /&gt;IFS=ascii(10) #again same character.&lt;BR /&gt;&lt;BR /&gt;which would be handy not only for clearly setting IFS but also for clearly restoring it!</description>
      <pubDate>Fri, 10 Feb 2006 11:34:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958704#M100991</guid>
      <dc:creator>Tracy_33</dc:creator>
      <dc:date>2006-02-10T11:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958705#M100992</link>
      <description>The typical way under the shell would be-&lt;BR /&gt; &lt;BR /&gt;bs=`echo "\010"`&lt;BR /&gt; &lt;BR /&gt;However, since linefeed is a special character used for record seperation within text files, I don't think it's going to work.&lt;BR /&gt; &lt;BR /&gt;If you set IFS to null, then I think you will get the results you are looking for.&lt;BR /&gt; &lt;BR /&gt;perl or awk might be better tools for string processing of a file.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 10 Feb 2006 11:42:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958705#M100992</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-02-10T11:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958706#M100993</link>
      <description>DING! a correct and specific answer, thanks; but now there's more.&lt;BR /&gt;&lt;BR /&gt;$IFS="\012"&lt;BR /&gt;should work to set IFS = linefeed aka newline, but no...&lt;BR /&gt;$ IX="     &lt;BR /&gt;&amp;gt; "        &lt;BR /&gt;$ echo $IX | od -b&lt;BR /&gt;0000000 012 012&lt;BR /&gt;0000002&lt;BR /&gt;$ IX="\012"&lt;BR /&gt;$ echo $IX | od -b&lt;BR /&gt;0000000 134 040 040 012&lt;BR /&gt;0000004&lt;BR /&gt;but&lt;BR /&gt;$ IX="\001\002\003\004\005\006\007\010\012\013\014\015\020"&lt;BR /&gt;$ echo $IX | od -b&lt;BR /&gt;0000000 001 002 003 004 005 006 007 010 012 013 014 015 020 012&lt;BR /&gt;0000016&lt;BR /&gt;$# what's happening here?  &lt;BR /&gt;$# and shouldn't IFS typically be \040\011\012 (space,tab,linefeed)?  mine seems to default to &lt;NOTHING&gt;, not even \000.&lt;/NOTHING&gt;</description>
      <pubDate>Fri, 10 Feb 2006 14:31:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958706#M100993</guid>
      <dc:creator>Tracy_33</dc:creator>
      <dc:date>2006-02-10T14:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958707#M100994</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;If you simply unset IFS you will preserve leading spaces and tabs upon reading.  No word splitting is done:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;OLDIFS=${IFS}&lt;BR /&gt;IFS=&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;    echo ${LINE}&lt;BR /&gt;done&lt;BR /&gt;IFS=${OLDIFS}&lt;BR /&gt;&lt;BR /&gt;Does this help?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 10 Feb 2006 14:53:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958707#M100994</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-10T14:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958708#M100995</link>
      <description>$# Yes that helps; both &lt;BR /&gt;$oldIFS=$IFS     #good idea&lt;BR /&gt;$# and&lt;BR /&gt;$IFS=&lt;BR /&gt;$# are good; using that IFS setting works.  so my questions become entirely academic, no quick answers:&lt;BR /&gt;&lt;BR /&gt;1) in the HPUX shell user guide (posix section) the intro says IFS behavior is different from Bourne, "IFS variable is effective only for read, results of parameter expansions and command substitution; it is always initialized."&lt;BR /&gt;and later in a table "Shell parms" it says&lt;BR /&gt;"IFS:Internal Field Separators (usually space, tab, and new-line), which are used to separate command words during command or parameter substitution and when using the read command."  OK, let's test that:&lt;BR /&gt;$sh                      &lt;BR /&gt;$echo $IFS | od -b&lt;BR /&gt;0000000 012&lt;BR /&gt;0000001&lt;BR /&gt;$# I see nothing here; does that mean od -b doesn't work?&lt;BR /&gt;$read line&lt;BR /&gt;   3spacesthentabhere:  thenspacehere: theend.&lt;BR /&gt;$echo $line&lt;BR /&gt;3spacesthentabhere: thenspacehere: theend.&lt;BR /&gt;$# so spaces and tabs are being removed, but why?  I sure didn't see them in IFS.&lt;BR /&gt;$IFS=&lt;BR /&gt;$echo $IFS | od -b&lt;BR /&gt;0000000 012&lt;BR /&gt;0000001&lt;BR /&gt;$read line&lt;BR /&gt;   3spacesthentabhere:  thenspacehere: theend.&lt;BR /&gt;$echo $line&lt;BR /&gt;   3spacesthentabhere:  thenspacehere: theend.&lt;BR /&gt;$# it's working now.  why?  &lt;BR /&gt;$# also, what's happening here?:&lt;BR /&gt;$IFS=&lt;BR /&gt;$read line&lt;BR /&gt;           tab3spacesthenthisthentab:   thenthisthentab:        theend.&lt;BR /&gt;$echo $line&lt;BR /&gt;           tab3spacesthenthisthentab:   thenthisthentab:        theend.&lt;BR /&gt;$echo $IFS | od -b&lt;BR /&gt;0000000 012&lt;BR /&gt;0000001&lt;BR /&gt;$IFS="\011\012\040"&lt;BR /&gt;$echo $IFS | od -b &lt;BR /&gt;0000000 134 040 040 040 134 040 040 040 134 040 040 012&lt;BR /&gt;0000014&lt;BR /&gt;$#WTF?&lt;BR /&gt;$IFS="&lt;BR /&gt;&amp;gt; "&lt;BR /&gt;$echo $IFS | od -b&lt;BR /&gt;0000000 012&lt;BR /&gt;0000001&lt;BR /&gt;$IFS="\011\012"&lt;BR /&gt;$echo $IFS | od -b&lt;BR /&gt;0000000 134 040 040 040 134 040 040 012&lt;BR /&gt;0000010&lt;BR /&gt;$#I have examples of \011 really being loaded to IFS, but not always.  any clues?  &lt;BR /&gt;$#I'm about to start smoking again.</description>
      <pubDate>Fri, 10 Feb 2006 18:18:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958708#M100995</guid>
      <dc:creator>Tracy_33</dc:creator>
      <dc:date>2006-02-10T18:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958709#M100996</link>
      <description>Space, tab, and new-line are special to the shell too.&lt;BR /&gt; &lt;BR /&gt;Try-&lt;BR /&gt;echo "$IFS" | od -b&lt;BR /&gt; &lt;BR /&gt;to see the contents.&lt;BR /&gt; &lt;BR /&gt;Rod Hills</description>
      <pubDate>Fri, 10 Feb 2006 18:44:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958709#M100996</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-02-10T18:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958710#M100997</link>
      <description>That last answer's pretty short but a lot to chew.  Thanks!</description>
      <pubDate>Fri, 10 Feb 2006 19:39:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958710#M100997</guid>
      <dc:creator>Tracy_33</dc:creator>
      <dc:date>2006-02-10T19:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: IFS Internal Field Separator</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958711#M100998</link>
      <description>sorry it took so long to pound echo's function into my thick skull.</description>
      <pubDate>Fri, 10 Feb 2006 19:43:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ifs-internal-field-separator/m-p/4958711#M100998</guid>
      <dc:creator>Tracy_33</dc:creator>
      <dc:date>2006-02-10T19:43:05Z</dc:date>
    </item>
  </channel>
</rss>

