<?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: '\' sripped in when reading a 'line' in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856348#M98232</link>
    <description>Hi,&lt;BR /&gt;on my HP-UX 11i this runs fine:&lt;BR /&gt;&lt;BR /&gt;while read -r LINE; do&lt;BR /&gt;   case "$LINE" in&lt;BR /&gt;      *find*) continue ;;&lt;BR /&gt;      *) echo "$LINE" &amp;gt;&amp;gt; newfile ;;&lt;BR /&gt;   esac&lt;BR /&gt;done &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;from man read:&lt;BR /&gt;    Options and Arguments&lt;BR /&gt;      read recognizes the following options and command-line arguments:&lt;BR /&gt;&lt;BR /&gt;           -r             Do not treat a backslash character in any special&lt;BR /&gt;                          way.  Consider each backslash to be part of the&lt;BR /&gt;                          input line.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
    <pubDate>Wed, 06 Sep 2006 03:50:44 GMT</pubDate>
    <dc:creator>Arturo Galbiati</dc:creator>
    <dc:date>2006-09-06T03:50:44Z</dc:date>
    <item>
      <title>'\' sripped in when reading a 'line'</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856344#M98228</link>
      <description>&lt;!--!*#--&gt;I came across a "pesky" situation where '\' is stripped when running a file through a 'while' loop and displaying content via either 'echo' or 'print' internal shell calls.&lt;BR /&gt;&lt;BR /&gt;The shell in question is HP-UX implementation of /usr/bin/ksh or 1989 Korn implementation.&lt;BR /&gt;&lt;BR /&gt;The idea is very simple:  dump crontab to a file and discard anything that I do not need.&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;while read LINE; do&lt;BR /&gt;   case "$LINE" in&lt;BR /&gt;      *find*) continue ;;&lt;BR /&gt;      *) echo "$LINE" &amp;gt;&amp;gt; newfile ;;&lt;BR /&gt;   esac&lt;BR /&gt;done &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;I replaced echo with 'print' and tried to use -r for 'raw', no help.  Each time '\' was stripped.  For example:&lt;BR /&gt;&lt;BR /&gt;find . -type f -exec ls -l {} \;&lt;BR /&gt;&lt;BR /&gt;became&lt;BR /&gt;&lt;BR /&gt;find . -type f -exec ls -l {} ;&lt;BR /&gt;&lt;BR /&gt;I finally ended up using 'sed' to do what I wanted, however, I would like to do everything in shell.&lt;BR /&gt;&lt;BR /&gt;So, my question is, how can I preserve '\' slash when reading a variable through either 'echo' or 'print' internal shell calls?&lt;BR /&gt;&lt;BR /&gt;P.S.  printf did not help either.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Mon, 04 Sep 2006 22:14:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856344#M98228</guid>
      <dc:creator>Bolek Mynarski</dc:creator>
      <dc:date>2006-09-04T22:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: '\' sripped in when reading a 'line'</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856345#M98229</link>
      <description>The read isn't killing. print -r will not convert the escape sequences but you do need to carefully watch your quoting.&lt;BR /&gt;&lt;BR /&gt;XX="AAA\tBBB"&lt;BR /&gt;print -r "${XX}"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Sep 2006 22:36:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856345#M98229</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-09-04T22:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: '\' sripped in when reading a 'line'</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856346#M98230</link>
      <description>Oh, and should add that just as there is a -r option for print there is also an equivalent -r option for read.&lt;BR /&gt;&lt;BR /&gt;XX="AAA\tBBB"&lt;BR /&gt;print -r "${XX}" &amp;gt; /var/tmp/myfile&lt;BR /&gt;&lt;BR /&gt;od -c /var/tmp/myfile # to convince yourself it's there&lt;BR /&gt;&lt;BR /&gt;read -r YY &amp;lt; /var/tmp/mfile&lt;BR /&gt;print -r "${YY}" # backslash should be intact</description>
      <pubDate>Mon, 04 Sep 2006 22:54:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856346#M98230</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-09-04T22:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: '\' sripped in when reading a 'line'</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856347#M98231</link>
      <description>In the shell for my Linux test system I need to use -e to make it interpret the escape, -E to stop it.&lt;BR /&gt;&lt;BR /&gt;'man ksh' gives on interesting description:&lt;BR /&gt;&lt;BR /&gt;"echo arg ...&lt;BR /&gt;  When the first arg does not begin with a -, and none of the arguments contain a \, then echo prints each of its arguments separated by a space and terminated by a new-line.&lt;BR /&gt;Otherwise, the behavior of echo is system dependent and print or printf described below should be used."&lt;BR /&gt;&lt;BR /&gt;'man echo' suggest the -n as replied before:&lt;BR /&gt;&lt;BR /&gt;"Notes&lt;BR /&gt;      Berkeley echo differs from this implementation.  The former does not implement the backslash escapes. However, the semantics of the \c escape can be obtained by using the -n option.  The echo command implemented as a built-in function of csh follows the Berkeley semantics (see csh(1))."&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Sep 2006 23:06:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856347#M98231</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-09-04T23:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: '\' sripped in when reading a 'line'</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856348#M98232</link>
      <description>Hi,&lt;BR /&gt;on my HP-UX 11i this runs fine:&lt;BR /&gt;&lt;BR /&gt;while read -r LINE; do&lt;BR /&gt;   case "$LINE" in&lt;BR /&gt;      *find*) continue ;;&lt;BR /&gt;      *) echo "$LINE" &amp;gt;&amp;gt; newfile ;;&lt;BR /&gt;   esac&lt;BR /&gt;done &amp;lt; file&lt;BR /&gt;&lt;BR /&gt;from man read:&lt;BR /&gt;    Options and Arguments&lt;BR /&gt;      read recognizes the following options and command-line arguments:&lt;BR /&gt;&lt;BR /&gt;           -r             Do not treat a backslash character in any special&lt;BR /&gt;                          way.  Consider each backslash to be part of the&lt;BR /&gt;                          input line.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Wed, 06 Sep 2006 03:50:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sripped-in-when-reading-a-line/m-p/3856348#M98232</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-09-06T03:50:44Z</dc:date>
    </item>
  </channel>
</rss>

