<?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: Awk Variable Substition in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018047#M96865</link>
    <description>NO problem,&lt;BR /&gt;&lt;BR /&gt;I am trying to do something with other parameters and formatting the input so ideally would like something to be able to do something all in one line&lt;BR /&gt;&lt;BR /&gt;i.e. &lt;BR /&gt;&lt;BR /&gt;| awk ' BEGIN { FS="\n" ; RS="" } { print $1 ", " $2 ", " $3 ", " &lt;STRIP&gt; ", " $6 } '&lt;/STRIP&gt;</description>
    <pubDate>Mon, 11 Dec 2006 10:56:58 GMT</pubDate>
    <dc:creator>gstonian</dc:creator>
    <dc:date>2006-12-11T10:56:58Z</dc:date>
    <item>
      <title>Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018040#M96858</link>
      <description>Hey, &lt;BR /&gt;&lt;BR /&gt;Just want to strip everything prior to the last backslash for a paramter in a file using awk.&lt;BR /&gt;&lt;BR /&gt;i.e.&lt;BR /&gt;&lt;BR /&gt;cat file | awk ' BEGIN { FS="\n" ; RS="" } { print $5 } '&lt;BR /&gt;Test\SQL Servers\Server1&lt;BR /&gt;Edinburgh\SQL Servers\Server2&lt;BR /&gt;London\SQL Servers\Server3&lt;BR /&gt;Test Servers\Server4&lt;BR /&gt;&lt;BR /&gt;to be &lt;BR /&gt;Server1&lt;BR /&gt;Server2&lt;BR /&gt;Server3&lt;BR /&gt;&lt;BR /&gt;Outside of awk I know i can do  ${variable##*\\} &lt;BR /&gt;but not sure how to get it to work alongside awk and everything I see appears to work on the first occurence i.e.&lt;BR /&gt;&lt;BR /&gt;awk ' BEGIN { FS="\n" ; RS="" } { print substr($5,(index($5, "\\")+1),20)  } ' &lt;BR /&gt;works on the first occurence of "\" but  doesn't handle any further occurences&lt;BR /&gt;&lt;BR /&gt;I'm sure I'm missing something simple here so please let me know ;-) &lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Dec 2006 09:30:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018040#M96858</guid>
      <dc:creator>gstonian</dc:creator>
      <dc:date>2006-12-11T09:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018041#M96859</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you just want the last part?&lt;BR /&gt;&lt;BR /&gt;awk -F\\ '{print $NF }' infile&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Mon, 11 Dec 2006 09:47:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018041#M96859</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2006-12-11T09:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018042#M96860</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;In Perl, dimply:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'print $1 if m/.*\\(.*)/' filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 11 Dec 2006 09:48:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018042#M96860</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-11T09:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018043#M96861</link>
      <description>Thanks but it's not the last part of the file, just simply the last part of the  parameter ($5) I want to print. There are other fields after this one $6,$7 etc. I just simplified the issue down . &lt;BR /&gt;&lt;BR /&gt;Thanks for the perl solution but would like to use awk if possible&lt;BR /&gt;&lt;BR /&gt;Cheers</description>
      <pubDate>Mon, 11 Dec 2006 09:52:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018043#M96861</guid>
      <dc:creator>gstonian</dc:creator>
      <dc:date>2006-12-11T09:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018044#M96862</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;OK, then in 'awk':&lt;BR /&gt;&lt;BR /&gt;# awk '{sub(/.+\\/, "",$0);print}' filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 11 Dec 2006 10:06:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018044#M96862</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-11T10:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018045#M96863</link>
      <description>Sounds like basename would be the simplest in your situation:&lt;BR /&gt;&lt;BR /&gt;# basename London\SQL Servers\Server3&lt;BR /&gt;LondonSQL&lt;BR /&gt;&lt;BR /&gt;Easiest awk would be:&lt;BR /&gt;awk -F'\' '{print $NF}'  filename&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Dec 2006 10:45:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018045#M96863</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2006-12-11T10:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018046#M96864</link>
      <description>Please excuse my ridiculous 'basename' suggestion above.</description>
      <pubDate>Mon, 11 Dec 2006 10:52:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018046#M96864</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2006-12-11T10:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018047#M96865</link>
      <description>NO problem,&lt;BR /&gt;&lt;BR /&gt;I am trying to do something with other parameters and formatting the input so ideally would like something to be able to do something all in one line&lt;BR /&gt;&lt;BR /&gt;i.e. &lt;BR /&gt;&lt;BR /&gt;| awk ' BEGIN { FS="\n" ; RS="" } { print $1 ", " $2 ", " $3 ", " &lt;STRIP&gt; ", " $6 } '&lt;/STRIP&gt;</description>
      <pubDate>Mon, 11 Dec 2006 10:56:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018047#M96865</guid>
      <dc:creator>gstonian</dc:creator>
      <dc:date>2006-12-11T10:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018048#M96866</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;just split the filed in request using '\' as seperator:&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN { FS="\n" ; RS="" }&lt;BR /&gt;{n=split($5,a,"\\"); if(n&amp;gt;1) print a[n]}' file&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Mon, 11 Dec 2006 11:47:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018048#M96866</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-12-11T11:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018049#M96867</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;sorry for the follow-up, but I missed your last post.&lt;BR /&gt;&lt;BR /&gt;To include my solution into in your code, use&lt;BR /&gt;the splitted result directly. If you set ORS, then there is no need to diddle with output formatting:&lt;BR /&gt;&lt;BR /&gt;| awk ' BEGIN { FS="\n" ; RS=""; ORS=" " }&lt;BR /&gt;{ n=split($5,a,"\\"); print $1,$2,$3,a[5],$6}'&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Mon, 11 Dec 2006 12:01:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018049#M96867</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-12-11T12:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018050#M96868</link>
      <description>Thanks for all your answers. I ended up taking your answers and ended up with using awk twice to get what I wanted, which was.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat file.out | awk -F\\ '{print $NF } ' | awk ' BEGIN { FS="\n" ; RS="" }  { print $1", "$2", "$3", "$4", "$5" "$7" "$8} '&lt;BR /&gt;&lt;BR /&gt;Hope someone else finds a use for this !</description>
      <pubDate>Tue, 12 Dec 2006 04:27:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018050#M96868</guid>
      <dc:creator>gstonian</dc:creator>
      <dc:date>2006-12-12T04:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Awk Variable Substition</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018051#M96869</link>
      <description>Thanks</description>
      <pubDate>Tue, 12 Dec 2006 04:29:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-variable-substition/m-p/5018051#M96869</guid>
      <dc:creator>gstonian</dc:creator>
      <dc:date>2006-12-12T04:29:02Z</dc:date>
    </item>
  </channel>
</rss>

