<?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 How to parse out fields using awk? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304212#M711652</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a shell script that finds and lists the full path to a file. (The filename always changes) I need to parse out all fields including the forward slashes because I only need the filename at the end of the path. &lt;BR /&gt;ex. /var/opt/filename&lt;BR /&gt;What would be the best way to do this?&lt;BR /&gt;&lt;BR /&gt;10 points ot any good answer.&lt;BR /&gt;TIA, Gino&lt;BR /&gt;</description>
    <pubDate>Mon, 14 Jun 2004 08:47:04 GMT</pubDate>
    <dc:creator>Gino Castoldi_2</dc:creator>
    <dc:date>2004-06-14T08:47:04Z</dc:date>
    <item>
      <title>How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304212#M711652</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a shell script that finds and lists the full path to a file. (The filename always changes) I need to parse out all fields including the forward slashes because I only need the filename at the end of the path. &lt;BR /&gt;ex. /var/opt/filename&lt;BR /&gt;What would be the best way to do this?&lt;BR /&gt;&lt;BR /&gt;10 points ot any good answer.&lt;BR /&gt;TIA, Gino&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jun 2004 08:47:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304212#M711652</guid>
      <dc:creator>Gino Castoldi_2</dc:creator>
      <dc:date>2004-06-14T08:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304213#M711653</link>
      <description>man basename&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 14 Jun 2004 08:52:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304213#M711653</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-06-14T08:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304214#M711654</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Are you looking for the "basename" command?&lt;BR /&gt;#man basename&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
      <pubDate>Mon, 14 Jun 2004 08:53:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304214#M711654</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2004-06-14T08:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304215#M711655</link>
      <description>This is confusing to me.&lt;BR /&gt; &lt;BR /&gt;Firstly "basename /var/opt/filename" will give you "filename".  However, I don't understand why you would need to do this because presumably you already had the filename in order to find it.&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jun 2004 08:53:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304215#M711655</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-06-14T08:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304216#M711656</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Mark: I'm using the 'find' command to locate the file so it returns the fullpath.&lt;BR /&gt;&lt;BR /&gt;All: The 'basename' command looks like the solution to me.&lt;BR /&gt;&lt;BR /&gt;10 points to any good answer.&lt;BR /&gt;TIA, Gino</description>
      <pubDate>Mon, 14 Jun 2004 08:55:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304216#M711656</guid>
      <dc:creator>Gino Castoldi_2</dc:creator>
      <dc:date>2004-06-14T08:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304217#M711657</link>
      <description>Also dirname returns the directory:&lt;BR /&gt;&lt;BR /&gt;# filevar=/var/adm/syslog/syslog.log&lt;BR /&gt;# basename $filevar&lt;BR /&gt;syslog.log&lt;BR /&gt;# dirname $filevar &lt;BR /&gt;/var/adm/syslog&lt;BR /&gt;# &lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 14 Jun 2004 08:58:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304217#M711657</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-06-14T08:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304218#M711658</link>
      <description>If you're using find, how about:&lt;BR /&gt;&lt;BR /&gt;find / -name filename -exec basename {} \;&lt;BR /&gt;&lt;BR /&gt;Mark Syder (like the drink but spelt different)</description>
      <pubDate>Mon, 14 Jun 2004 09:02:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304218#M711658</guid>
      <dc:creator>MarkSyder</dc:creator>
      <dc:date>2004-06-14T09:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304219#M711659</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;basename $FILE &lt;BR /&gt;and &lt;BR /&gt;dirname $FILE &lt;BR /&gt;are the best solution, but if you like awk:&lt;BR /&gt;PATH=$(echo $FILE|awk -F/ '{$NF="";print}' | sed 's? ?/?g'&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Mon, 14 Jun 2004 09:08:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304219#M711659</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2004-06-14T09:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304220#M711660</link>
      <description>Hi Gino,&lt;BR /&gt;&lt;BR /&gt;sorry, but the find command doens't already show the fullpath?&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;filename under /pippo/pluto&lt;BR /&gt;# find / -name filename&lt;BR /&gt;/pippo/pluto/filename&lt;BR /&gt;&lt;BR /&gt;It returns fullpath then I don't understand your problem.&lt;BR /&gt;Otherwise I hope that other ITRC guys will help you better than me.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Ettore</description>
      <pubDate>Mon, 14 Jun 2004 09:08:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304220#M711660</guid>
      <dc:creator>Fabio Ettore</dc:creator>
      <dc:date>2004-06-14T09:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304221#M711661</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Fabio: When I run the find command while searching for a particular file it returns the full path with the file itself.&lt;BR /&gt;I just need the file name by itself, I want to remove the rest of the string (which includes the full path).&lt;BR /&gt;&lt;BR /&gt;10 points to any good answer.&lt;BR /&gt;TIA, Gino</description>
      <pubDate>Mon, 14 Jun 2004 09:12:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304221#M711661</guid>
      <dc:creator>Gino Castoldi_2</dc:creator>
      <dc:date>2004-06-14T09:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304222#M711662</link>
      <description>Ok, now I understand your problem.&lt;BR /&gt;I saw your first post but the second one diverted me:&lt;BR /&gt;&lt;BR /&gt;***************&lt;BR /&gt;Mark: I'm using the 'find' command to locate the file so it returns the fullpath.&lt;BR /&gt;***************&lt;BR /&gt;&lt;BR /&gt;No points for me....&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Ettore</description>
      <pubDate>Mon, 14 Jun 2004 09:15:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304222#M711662</guid>
      <dc:creator>Fabio Ettore</dc:creator>
      <dc:date>2004-06-14T09:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304223#M711664</link>
      <description>Ok.....&lt;BR /&gt;find /mydir -print | xargs basename?&lt;BR /&gt;NO.  THAT won't work. &lt;BR /&gt;How about... &lt;BR /&gt;find /mydir | awk -F/ '// {print $NF}'&lt;BR /&gt;Yep.  That looks right.  I saw the awk command in the forums above. &lt;BR /&gt;&lt;BR /&gt;But if you are looking for the base name perhaps you are just looking for the file?&lt;BR /&gt;If that's the case....."I want to find a file that begins with "billy".&lt;BR /&gt;find /mydir -name "billy*" -print | awk -F/ '// {print $NF}'&lt;BR /&gt;&lt;BR /&gt;In awk the -F/ is means separate the fields by the / character.&lt;BR /&gt;The $NF means the current number of fields on that line.&lt;BR /&gt;So print $NF means print the last field on the line.  &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Jun 2004 07:31:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304223#M711664</guid>
      <dc:creator>Steve Post</dc:creator>
      <dc:date>2004-06-15T07:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304224#M711666</link>
      <description>basename and dirname do a great job in parsing just the name and the path respectively. However, the shell already knows how to do this so you can bypass awk, sed and basename with something like this:&lt;BR /&gt; &lt;BR /&gt;find /somewhere | while read&lt;BR /&gt;do&lt;BR /&gt;echo ${REPLY##*/}&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Tue, 15 Jun 2004 07:52:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304224#M711666</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2004-06-15T07:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304225#M711668</link>
      <description># perl -MFile::Find -MCwd=abs_path 'find (sub { my $filename = $_ ; my $relative_name = $File::Find::name; my $fullname = abs_path ($_) }, @ARGV)' dir dir dir&lt;BR /&gt;&lt;BR /&gt;Modify to your liking&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Tue, 15 Jun 2004 08:11:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304225#M711668</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-06-15T08:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304226#M711670</link>
      <description>If you are using ksh, you can use variable manipulation.&lt;BR /&gt;&lt;BR /&gt;If the variable is stored in variable "fn", try this:&lt;BR /&gt;&lt;BR /&gt;echo ${fn##*/}&lt;BR /&gt;&lt;BR /&gt;and it should show you just the file name.&lt;BR /&gt;&lt;BR /&gt;The "##" removes the large left pattern. &lt;BR /&gt;The "*/" is the pattern to be removed.&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Tue, 15 Jun 2004 08:50:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304226#M711670</guid>
      <dc:creator>Tom Maloy</dc:creator>
      <dc:date>2004-06-15T08:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse out fields using awk?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304227#M711673</link>
      <description>Hai.&lt;BR /&gt;&lt;BR /&gt; You can get the directory name and pathname of all regular files using,&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt; echo "   DIR-NAME      FILE-NAME"&lt;BR /&gt;find / -type f | while read file; do&lt;BR /&gt;   echo "`dirname $file`  `basename $file`"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;For other files like character files,block devices change the -type X value from man find&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Muthukumar.</description>
      <pubDate>Sat, 19 Jun 2004 04:32:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-parse-out-fields-using-awk/m-p/3304227#M711673</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-06-19T04:32:00Z</dc:date>
    </item>
  </channel>
</rss>

