<?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: analyzing ipfilter logs, need shell script advice in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235979#M675835</link>
    <description># awk '{if ($5~"x$") {$5=""} print $0}' file&lt;BR /&gt;</description>
    <pubDate>Tue, 20 Apr 2010 15:17:28 GMT</pubDate>
    <dc:creator>Raj D.</dc:creator>
    <dc:date>2010-04-20T15:17:28Z</dc:date>
    <item>
      <title>analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235972#M675828</link>
      <description>All,&lt;BR /&gt;I'm trying to come up with a way to import ipfilter logs into Microsfot Access. One problem is the logs sometimes have an extra column. For example the first two lines have nine columns, and the third line has eight columns:&lt;BR /&gt;&lt;BR /&gt;apr 20 joe 0.0.0.0 2x port 15000 len 20&lt;BR /&gt;apr 21 bob 0.0.0.1 3x port 15000 len 25&lt;BR /&gt;apr 21 dave 0.0.0.3 port 15000 len 28&lt;BR /&gt;&lt;BR /&gt;The first two lines have a column "2x" and "3x" that don't show up in the third line. This makes it hard to import the file into an Access table. I don't need that column with the *x*, I'd like to remove it from every line that contains the extra column while keeping the rest of the line. A simple "grep -v x filename &amp;gt; output.txt will produce a file with all the lines not containing an "x", but I want those lines, I just want to remove the expression that contains the "x".&lt;BR /&gt;&lt;BR /&gt;What utility can do this? Can sed, awk, or cut go through each line and remove just the expression with the "x" character in it? I need to remove the entire expression such as "2x", "13x", and so forth, while retaining the rest of the information in the line. The columns are separated by spaces. Maybe there's a way to tell cut "check the number of columns, if there are nine then remove the fifth one, otherwise do nothing"? &lt;BR /&gt;&lt;BR /&gt;Also if anyone knows of a tool that can take ipfilter logs and analyze them and create a report please let me know. Thanks,&lt;BR /&gt;&lt;BR /&gt;Brian</description>
      <pubDate>Tue, 20 Apr 2010 13:24:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235972#M675828</guid>
      <dc:creator>Brian Bartley</dc:creator>
      <dc:date>2010-04-20T13:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235973#M675829</link>
      <description>&lt;!--!*#--&gt;If it can't be done with "sed", then it's not&lt;BR /&gt;worth doing, I always say.&lt;BR /&gt;&lt;BR /&gt;$ echo 'apr 21 dave 0.0.0.3 port 15000 len 28' | sed -e 's/ [0-9]*x / /'&lt;BR /&gt;apr 21 dave 0.0.0.3 port 15000 len 28&lt;BR /&gt;&lt;BR /&gt;$ echo 'apr 20 joe 0.0.0.0 2x port 15000 len 20' | sed -e 's/ [0-9]*x / /'&lt;BR /&gt;apr 20 joe 0.0.0.0 port 15000 len 20&lt;BR /&gt;&lt;BR /&gt;You could also pretend that you're writing&lt;BR /&gt;something like a real computer program, and&lt;BR /&gt;use "read" to (try to) suck in nine tokens:&lt;BR /&gt;&lt;BR /&gt;      read a b c d e f g h i&lt;BR /&gt;&lt;BR /&gt;use "if" to see if the last one is empty:&lt;BR /&gt;&lt;BR /&gt;      if [ -z "$i" ] ; then&lt;BR /&gt;&lt;BR /&gt;and then write out the stuff you'd like,&lt;BR /&gt;accordingly.&lt;BR /&gt;&lt;BR /&gt;As usual, there may be more than one way to&lt;BR /&gt;solve a problem like this.</description>
      <pubDate>Tue, 20 Apr 2010 13:49:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235973#M675829</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-04-20T13:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235974#M675830</link>
      <description>Hi Brian:&lt;BR /&gt;&lt;BR /&gt;If appears that it's the fifth column you don't want when there are more then eight columns.  Hence:&lt;BR /&gt;&lt;BR /&gt;# awk '{if (NF&amp;gt;8) {$5=""};print}' file&lt;BR /&gt;&lt;BR /&gt;...will snip out the extra data.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 20 Apr 2010 13:53:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235974#M675830</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-04-20T13:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235975#M675831</link>
      <description>&lt;!--!*#--&gt;&amp;gt; ...will snip out the extra data.&lt;BR /&gt;&lt;BR /&gt;But it leaves in that unsightly extra space.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] sed -e 's/ [0-9]*x / /'&lt;BR /&gt;&lt;BR /&gt;Note that a more complex "sed" command could&lt;BR /&gt;effectively determine the token count, and&lt;BR /&gt;act accordingly:&lt;BR /&gt;&lt;BR /&gt;$ echo 'aa bb' | \&lt;BR /&gt; sed -e 's/^\([^ ][^ ]*\)  *[^ ]*  *\([^ ][^ ]*\)$/\1 \2/'&lt;BR /&gt;aa bb&lt;BR /&gt;&lt;BR /&gt;$ echo 'aa bb cc' | \&lt;BR /&gt; sed -e 's/^\([^ ][^ ]*\)  *[^ ]*  *\([^ ][^ ]*\)$/\1 \2/'&lt;BR /&gt;aa cc&lt;BR /&gt;&lt;BR /&gt;Some shortening is possible if your "sed"&lt;BR /&gt;accommodates fancy regular expressions, but&lt;BR /&gt;I'll admit that it can get ugly.</description>
      <pubDate>Tue, 20 Apr 2010 14:25:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235975#M675831</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-04-20T14:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235976#M675832</link>
      <description>Steven,&lt;BR /&gt;Will this - [0-9]*x - account for any expression that ends in "x" with any number of integers preceeding it? Sometimes it's 2x, or 121x, or even 1232x. Maybe I should leave out the [0-9] and let it operate on any expression that ends in "x"? &lt;BR /&gt;&lt;BR /&gt;Also, when I'm ready to use a file as input could you please give the syntax for the read command, would it be &lt;BR /&gt;&lt;BR /&gt;while read &lt;NOT sure="" what="" to="" put="" as="" argument="" here..=""&gt;&lt;/NOT&gt;do&lt;BR /&gt;&lt;SED operations=""&gt;&lt;BR /&gt;done &amp;lt; input file&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Brian&lt;BR /&gt;&lt;/SED&gt;</description>
      <pubDate>Tue, 20 Apr 2010 14:38:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235976#M675832</guid>
      <dc:creator>Brian Bartley</dc:creator>
      <dc:date>2010-04-20T14:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235977#M675833</link>
      <description>&lt;!--!*#--&gt;&amp;gt; Will this - [0-9]*x - account for any [...]&lt;BR /&gt;&lt;BR /&gt;      man sed&lt;BR /&gt;      man regex&lt;BR /&gt;&lt;BR /&gt;That was the intention.  But, by itself,&lt;BR /&gt;it'll attack (almost) any token on the line. &lt;BR /&gt;And, as shown, you can play with this stuff&lt;BR /&gt;interactively, so if you have doubts, then&lt;BR /&gt;run the experiment.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Maybe I should [...]&lt;BR /&gt;&lt;BR /&gt;_You_ get to decide what you really want to&lt;BR /&gt;do.  There aren't any month name&lt;BR /&gt;abbreviations which end in "x", but I don't&lt;BR /&gt;know all your users' names.  Many things are&lt;BR /&gt;possible.  Looking for "&lt;DIGITS&gt;x" seemed&lt;BR /&gt;safer than "&lt;ANY_CHARACTERS&gt;x".&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] syntax for the read command [...]&lt;BR /&gt;&lt;BR /&gt;What was wrong with:&lt;BR /&gt;      read a b c d e f g h i&lt;BR /&gt;?&lt;BR /&gt;&lt;BR /&gt;      man &lt;YOUR_SHELL&gt;&lt;BR /&gt;&lt;BR /&gt;Look for "read".&lt;BR /&gt;&lt;BR /&gt;There are oodles of shell scripting primers&lt;BR /&gt;out there on this new-fangled Inter-Web&lt;BR /&gt;thing.&lt;/YOUR_SHELL&gt;&lt;/ANY_CHARACTERS&gt;&lt;/DIGITS&gt;</description>
      <pubDate>Tue, 20 Apr 2010 15:08:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235977#M675833</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-04-20T15:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235978#M675834</link>
      <description>Hi (again) Brian:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Steven: But it leaves in that unsightly extra space.&lt;BR /&gt;&lt;BR /&gt;But who cares given that the ultimate goal is to import the filtered log into Microsoft software?&lt;BR /&gt;&lt;BR /&gt;If that truly bothers you, you could do:&lt;BR /&gt;&lt;BR /&gt;# awk '{if (NF&amp;gt;8) {$5=""};print}' file|tr -s " "&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 20 Apr 2010 15:10:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235978#M675834</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-04-20T15:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235979#M675835</link>
      <description># awk '{if ($5~"x$") {$5=""} print $0}' file&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Apr 2010 15:17:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235979#M675835</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2010-04-20T15:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235980#M675836</link>
      <description>&lt;!--!*#--&gt;&amp;gt; But who cares [...]&lt;BR /&gt;&lt;BR /&gt;I said "unsightly", not "fatal".</description>
      <pubDate>Tue, 20 Apr 2010 15:49:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235980#M675836</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-04-20T15:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235981#M675837</link>
      <description>Thanks for all replies, once again this forum has helped me considerably.&lt;BR /&gt;&lt;BR /&gt;Brian</description>
      <pubDate>Tue, 20 Apr 2010 16:15:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235981#M675837</guid>
      <dc:creator>Brian Bartley</dc:creator>
      <dc:date>2010-04-20T16:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: analyzing ipfilter logs, need shell script advice</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235982#M675838</link>
      <description>If you want to remove that column, you can also re-print out each line&lt;BR /&gt;awk '&lt;BR /&gt;NF == 8 { print $0; next }&lt;BR /&gt;{ print $1, $2, $3, $4, $6, $7, $8, $9 }' file&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Apr 2010 23:59:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/analyzing-ipfilter-logs-need-shell-script-advice/m-p/5235982#M675838</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-04-20T23:59:08Z</dc:date>
    </item>
  </channel>
</rss>

