<?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: split on \ in awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014866#M912072</link>
    <description>Eureka!!  After taking A. Clay's recommendation about wrapping nested commands in () instead of single back-quotes the command is now working and producing the desired results.&lt;BR /&gt;&lt;BR /&gt;Can someone explain what the difference is? Since I don't get much training, I'm not up to speed on all the latest stuff (or even some of the not-so-latest stuff).&lt;BR /&gt;&lt;BR /&gt;Thanks for all your input.&lt;BR /&gt;&lt;BR /&gt;Don</description>
    <pubDate>Thu, 03 Jul 2003 18:55:36 GMT</pubDate>
    <dc:creator>Don Spare</dc:creator>
    <dc:date>2003-07-03T18:55:36Z</dc:date>
    <item>
      <title>split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014858#M912064</link>
      <description>I am trying to build a script that differentiates between Unix and Windows file name syntax - the main difference being Unix directories are separted with "/" and Windows with "\". In particular, I am trying to extract the Oracle version from a file specification on the assumption that the last group of characters after the "/" or "\" is the version number that I want. In the example below I can get a proper response from the Unix side but the Windows side always returns NULL which I am taking to mean that the split is not finding the proper delimiter. Any clues?&lt;BR /&gt;Is there a special way to refer to \ within awk so it can be used as a field delimiter?&lt;BR /&gt;&lt;BR /&gt;if [ "`grep $ORACLE_SID $MAP_DIR/system_orabase_nt`" = "" ]; then&lt;BR /&gt;   ORACLE_VERSION=`grep -i "$HOSTNAME $ORACLE_SID " $MAP_DIR/system_orabase |            awk '{split($4,a,"/"); print a[4] }'`&lt;BR /&gt;   echo "Found in system_orabase"&lt;BR /&gt;else&lt;BR /&gt;   ORACLE_VERSION=`grep -i "$REAL_HOSTNAME $ORACLE_SID " $MAP_DIR/system_orabase_nt |            awk '{split($4,a,"\5c"); print a[4] }'`&lt;BR /&gt;   echo "Found in system_orabase_nt"&lt;BR /&gt;fi&lt;BR /&gt;echo "ORACLE_VERSION = $ORACLE_VERSION"&lt;BR /&gt;&lt;BR /&gt;The 2 data files are attached.</description>
      <pubDate>Thu, 03 Jul 2003 16:43:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014858#M912064</guid>
      <dc:creator>Don Spare</dc:creator>
      <dc:date>2003-07-03T16:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014859#M912065</link>
      <description>I could only attach 1 file. Here is the 2nd.</description>
      <pubDate>Thu, 03 Jul 2003 16:43:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014859#M912065</guid>
      <dc:creator>Don Spare</dc:creator>
      <dc:date>2003-07-03T16:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014860#M912066</link>
      <description>You simply need to 'escape' the backslash with a backslash. instead of "\5c" or "\" use "\\" to generate a SINGLE backslash.&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jul 2003 16:51:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014860#M912066</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-03T16:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014861#M912067</link>
      <description>I tried that but I still don't get the split I'm looking for. The end result is a null.</description>
      <pubDate>Thu, 03 Jul 2003 17:02:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014861#M912067</guid>
      <dc:creator>Don Spare</dc:creator>
      <dc:date>2003-07-03T17:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014862#M912068</link>
      <description>Try&lt;BR /&gt;&lt;BR /&gt;awk -F"\" '{print $4}' ......file....&lt;BR /&gt;&lt;BR /&gt;Tim</description>
      <pubDate>Thu, 03 Jul 2003 17:16:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014862#M912068</guid>
      <dc:creator>Tim D Fulford</dc:creator>
      <dc:date>2003-07-03T17:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014863#M912069</link>
      <description>My awk test just worked fine. I suggest that you eliminate the awk part of the above commands and examine the output first. I think your problem must be earlier in the chain because the "\\" absolutely will work. In fact an alternate method to avoid the split is to specify the field separator again escaping the backslash:&lt;BR /&gt;&lt;BR /&gt;awk -F\\ '{print $4}'&lt;BR /&gt;&lt;BR /&gt;will work and is a little more obvious.&lt;BR /&gt;&lt;BR /&gt;I would surrond each shell var with ${}'s e.g. ${HOSTNAME} and replace the archaic `command` with $(command) -- that becomes especially important when you need to nest commands.&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jul 2003 17:17:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014863#M912069</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-03T17:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014864#M912070</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Perhaps not the answere of the awk question but to get the Oracle version out of the string, try the following:&lt;BR /&gt;basename `echo 'C:\Oracle\9.2.0' |tr "\134" /`&lt;BR /&gt;You can use the same command both for Unix and windows filenames. This  tr statement does not change Unix filnames.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jul 2003 18:27:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014864#M912070</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2003-07-03T18:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014865#M912071</link>
      <description>I'm beginning to think this might have something to do with my environment or maybe I'm out of rev on patches for awk or something. I got the -F\\ switch to work when I put the first $4 into a separate variable and then echoed the variable piped through awk -F\\ '{print $3}'.   (Yea $3 is correct. I had it wrong in the original example but that is not the problem.) However, when I try to pipe it all together the result is null. I even tried doing the awk in 2 steps, eg. -&lt;BR /&gt;&lt;BR /&gt;awk '{print $4}' | awk -F\\ '{print $3}'&lt;BR /&gt;&lt;BR /&gt;but that didn't work either.&lt;BR /&gt;&lt;BR /&gt;A. Clay,  I don't doubt that it should work, all I know is that it doesn't in my environment. I am running ksh vs sh. Could that be an issue?&lt;BR /&gt;&lt;BR /&gt;Don</description>
      <pubDate>Thu, 03 Jul 2003 18:44:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014865#M912071</guid>
      <dc:creator>Don Spare</dc:creator>
      <dc:date>2003-07-03T18:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014866#M912072</link>
      <description>Eureka!!  After taking A. Clay's recommendation about wrapping nested commands in () instead of single back-quotes the command is now working and producing the desired results.&lt;BR /&gt;&lt;BR /&gt;Can someone explain what the difference is? Since I don't get much training, I'm not up to speed on all the latest stuff (or even some of the not-so-latest stuff).&lt;BR /&gt;&lt;BR /&gt;Thanks for all your input.&lt;BR /&gt;&lt;BR /&gt;Don</description>
      <pubDate>Thu, 03 Jul 2003 18:55:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014866#M912072</guid>
      <dc:creator>Don Spare</dc:creator>
      <dc:date>2003-07-03T18:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: split on \ in awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014867#M912073</link>
      <description>In the font I'm using it is very difficult to distinguish the backticks from the single quotes so I can't really say what you fixed; however, disciplined shell programmer will ALWAYS enclose shell variables in {}'s and also tend to enclose commands in ()'s rather than ``'s. I mainly suggested the change because when I have to ask what this quote is doing .... there's probably a better way.&lt;BR /&gt;&lt;BR /&gt;Using the ()'s it is so much easier to find the single quotes, double quotes, and escaped quotes.&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Jul 2003 19:22:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/split-on-in-awk/m-p/3014867#M912073</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-03T19:22:00Z</dc:date>
    </item>
  </channel>
</rss>

