<?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 awk / cut  script help .. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545087#M369876</link>
    <description>I have the file with the following info:&lt;BR /&gt;&lt;BR /&gt;/abc/def/myfile.txt&lt;BR /&gt;/qwe/rty/yui/myfile2&lt;BR /&gt;/a/b/c/d/mylog.log&lt;BR /&gt;&lt;BR /&gt;In other words the files may or may not have extensions and will be in a variety of directories. &lt;BR /&gt;&lt;BR /&gt;I would like my output to be like this:&lt;BR /&gt;/abc/def/&lt;BR /&gt;myfile.txt&lt;BR /&gt;&lt;BR /&gt;/qwe/rty/yui/&lt;BR /&gt;myfile2&lt;BR /&gt;&lt;BR /&gt;/a/b/c/d/&lt;BR /&gt;mylog.log&lt;BR /&gt;&lt;BR /&gt;--------------------------------&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;for file in `cat files`&lt;BR /&gt;do&lt;BR /&gt;echo $file | do something to get the file name&lt;BR /&gt;echo $file | do something to get the directory of the file name&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Thanks !</description>
    <pubDate>Mon, 07 Dec 2009 02:48:40 GMT</pubDate>
    <dc:creator>rleon</dc:creator>
    <dc:date>2009-12-07T02:48:40Z</dc:date>
    <item>
      <title>awk / cut  script help ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545087#M369876</link>
      <description>I have the file with the following info:&lt;BR /&gt;&lt;BR /&gt;/abc/def/myfile.txt&lt;BR /&gt;/qwe/rty/yui/myfile2&lt;BR /&gt;/a/b/c/d/mylog.log&lt;BR /&gt;&lt;BR /&gt;In other words the files may or may not have extensions and will be in a variety of directories. &lt;BR /&gt;&lt;BR /&gt;I would like my output to be like this:&lt;BR /&gt;/abc/def/&lt;BR /&gt;myfile.txt&lt;BR /&gt;&lt;BR /&gt;/qwe/rty/yui/&lt;BR /&gt;myfile2&lt;BR /&gt;&lt;BR /&gt;/a/b/c/d/&lt;BR /&gt;mylog.log&lt;BR /&gt;&lt;BR /&gt;--------------------------------&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;for file in `cat files`&lt;BR /&gt;do&lt;BR /&gt;echo $file | do something to get the file name&lt;BR /&gt;echo $file | do something to get the directory of the file name&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Thanks !</description>
      <pubDate>Mon, 07 Dec 2009 02:48:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545087#M369876</guid>
      <dc:creator>rleon</dc:creator>
      <dc:date>2009-12-07T02:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: awk / cut  script help ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545088#M369877</link>
      <description>&lt;!--!*#--&gt;for file in $(&amp;lt; files); do&lt;BR /&gt;   echo $(dirname $file)&lt;BR /&gt;   echo $(basename $file)&lt;BR /&gt;   echo&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I output the directory first, since that's what your required output format wanted.&lt;BR /&gt;Instead of dirname(1) and basename(1) you can use shell Parameter Substitution:&lt;BR /&gt;echo ${file%/*}&lt;BR /&gt;echo ${file##*/}</description>
      <pubDate>Mon, 07 Dec 2009 03:29:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545088#M369877</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-12-07T03:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: awk / cut  script help ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545089#M369878</link>
      <description>There are two standard HP-UX commands that will do *exactly* what you need in your script above. Take a look at the man pages for "basename" and "dirname"</description>
      <pubDate>Mon, 07 Dec 2009 03:33:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545089#M369878</guid>
      <dc:creator>TTr</dc:creator>
      <dc:date>2009-12-07T03:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: awk / cut  script help ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545090#M369879</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Using PERL ...&lt;BR /&gt;&lt;BR /&gt;$ perl -pe "s;(/[^/]+)$;/\n\1\n;" x&lt;BR /&gt;/abc/def/&lt;BR /&gt;/myfile.txt&lt;BR /&gt;&lt;BR /&gt;/qwe/rty/yui/&lt;BR /&gt;/myfile2&lt;BR /&gt;&lt;BR /&gt;/a/b/c/d/&lt;BR /&gt;/mylog.log&lt;BR /&gt;&lt;BR /&gt;s;(/  = substitute a slash&lt;BR /&gt;[^/]+ = followed by a bunch of non-slashes&lt;BR /&gt;) = which are to be remembered as \1&lt;BR /&gt;$ = at the end of a line;&lt;BR /&gt;; = and replace with&lt;BR /&gt;/\n\1\n; = a fresh slash, a newline, the remembered non-slashes and a bonus newline.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Similar, using AWK as per subject line:&lt;BR /&gt;&lt;BR /&gt;$ perl -pe "s;(/[^/]+)$;/\n\1\n;" x&lt;BR /&gt;/abc/def/&lt;BR /&gt;/myfile.txt&lt;BR /&gt;&lt;BR /&gt;/qwe/rty/yui/&lt;BR /&gt;/myfile2&lt;BR /&gt;&lt;BR /&gt;/a/b/c/d/&lt;BR /&gt;/mylog.log&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now if there were multiple entries for one directory...&lt;BR /&gt;1) would you perhaps want one header, and multiple details? &lt;BR /&gt;2) Even if they are not adjacent in the input stream?&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Dec 2009 04:53:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545090#M369879</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-12-07T04:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: awk / cut  script help ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545091#M369880</link>
      <description>Oops, bad repeat cut &amp;amp; paste. Meant to offer:&lt;BR /&gt;&lt;BR /&gt;$ awk -F/ '{sub ($NF "$","\n" $NF "\n",$0); print}' x&lt;BR /&gt;/abc/def/&lt;BR /&gt;myfile.txt&lt;BR /&gt;&lt;BR /&gt;/qwe/rty/yui/&lt;BR /&gt;myfile2&lt;BR /&gt;&lt;BR /&gt;/a/b/c/d/&lt;BR /&gt;mylog.log&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Just change the standard whitespace field seperator by a slash.&lt;BR /&gt;Look for the last field value ($NF) by anchoring it at the end of line with that $.&lt;BR /&gt;This is such that a file "b" in directory a/b/c would not find the first matching string /b/&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Dec 2009 04:56:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545091#M369880</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-12-07T04:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: awk / cut  script help ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545092#M369881</link>
      <description>&lt;!--!*#--&gt;Dennis, you don't need the extra echo ;)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;for file in $(&amp;lt; files); do&lt;BR /&gt;&amp;gt;   echo $(dirname $file)&lt;BR /&gt;&amp;gt;   echo $(basename $file)&lt;BR /&gt;&amp;gt;   echo&lt;BR /&gt;&amp;gt;done&lt;BR /&gt;&lt;BR /&gt;for file in $(&amp;lt; files); do&lt;BR /&gt;   dirname $file&lt;BR /&gt;   basename $file&lt;BR /&gt;   echo&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Dec 2009 14:28:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545092#M369881</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2009-12-08T14:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: awk / cut  script help ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545093#M369882</link>
      <description>HI,&lt;BR /&gt;small improvement to show the directory only when chnaged (or first time)&lt;BR /&gt;&lt;BR /&gt;DirNam=&lt;BR /&gt;for file in $(&amp;lt; files); do&lt;BR /&gt;   if [[ $DirNam != $(dirname $file) ]]; then&lt;BR /&gt;     DirNam=$(dirname $file)&lt;BR /&gt;     echo $DirNam&lt;BR /&gt;   fi&lt;BR /&gt;   basename $file&lt;BR /&gt;   echo&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Dec 2009 10:47:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-cut-script-help/m-p/4545093#M369882</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2009-12-09T10:47:07Z</dc:date>
    </item>
  </channel>
</rss>

