<?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: parse out last bit of file name in scripts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186564#M163927</link>
    <description>or you could do something like this&lt;BR /&gt;&lt;BR /&gt;server="pass.change.some_server3"&lt;BR /&gt;file=${server##*.}&lt;BR /&gt;print $file</description>
    <pubDate>Mon, 09 Feb 2004 11:57:16 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2004-02-09T11:57:16Z</dc:date>
    <item>
      <title>parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186561#M163924</link>
      <description>I have a script that runs a for loop.&lt;BR /&gt;&lt;BR /&gt;for i in `cat /tmp/file`&lt;BR /&gt;do&lt;BR /&gt;yada&lt;BR /&gt;send output to file.&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;The /tmp/file contains...&lt;BR /&gt;pass.change.some_server1&lt;BR /&gt;pass.change.some_server2&lt;BR /&gt;pass.change.some_server3&lt;BR /&gt;pass.change.some_server4&lt;BR /&gt;&lt;BR /&gt;I am trying to add mailing of the output file, but would like to add to the subject line the end part of the pass.change.some_server1.&lt;BR /&gt;so just some_server1.&lt;BR /&gt;&lt;BR /&gt;I thought I could do it with an awk script but I have not been able to get it to work.&lt;BR /&gt;&lt;BR /&gt;I want to take $i and parse it down to the last part of some_server1 and store that is a variable then use it in the subject line.</description>
      <pubDate>Mon, 09 Feb 2004 11:41:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186561#M163924</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2004-02-09T11:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186562#M163925</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I would do something like this (if I understood your requirement correctly)&lt;BR /&gt;&lt;BR /&gt;//&lt;BR /&gt;EMAIL=your_id@your_domain.com&lt;BR /&gt;for FILE in $(cat /tmp/file)&lt;BR /&gt;do&lt;BR /&gt;SERVER=$(echo $FILE|awk '{FS=".";print $3}')&lt;BR /&gt;mailx -s "Something on $SERVER" $EMAIL &amp;lt; $FILE&lt;BR /&gt;done&lt;BR /&gt;//&lt;BR /&gt;&lt;BR /&gt;SERVER=$(echo $FILE|awk '{FS=".";print $3}')&lt;BR /&gt;&lt;BR /&gt;Is the key.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Feb 2004 11:47:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186562#M163925</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-02-09T11:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186563#M163926</link>
      <description>for i in $(cat /tmpfile)&lt;BR /&gt;do&lt;BR /&gt;  XX=$(echo "${i}" | awk -F '.' '{print $NF}')&lt;BR /&gt;  echo "XX = ${XX}"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The trick is to define '.' as awk's field separator and then print the last field ($NF) on each line.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Feb 2004 11:50:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186563#M163926</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-02-09T11:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186564#M163927</link>
      <description>or you could do something like this&lt;BR /&gt;&lt;BR /&gt;server="pass.change.some_server3"&lt;BR /&gt;file=${server##*.}&lt;BR /&gt;print $file</description>
      <pubDate>Mon, 09 Feb 2004 11:57:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186564#M163927</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-02-09T11:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186565#M163928</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you could also extract it with&lt;BR /&gt;expr "$LINE" : ".*\(some_server.*\).*"&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Feb 2004 12:02:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186565#M163928</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2004-02-09T12:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186566#M163929</link>
      <description>if this is always the 3rd field (separator=".") then you can write :&lt;BR /&gt;for fln in $(cat /tmp/file)&lt;BR /&gt;do&lt;BR /&gt;server=$(echo $fln | cut -f3 -d".")&lt;BR /&gt;&lt;BR /&gt;send output to file.&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Mon, 09 Feb 2004 12:05:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186566#M163929</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2004-02-09T12:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186567#M163930</link>
      <description>for i in `cat /tmp/file`&lt;BR /&gt;do&lt;BR /&gt;server=$( print $i | sed -e 's/^.*\.//' )&lt;BR /&gt;print $server&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Should give you:&lt;BR /&gt;&lt;BR /&gt;some_server1&lt;BR /&gt;some_server2&lt;BR /&gt;some_server3&lt;BR /&gt;some_server4</description>
      <pubDate>Mon, 09 Feb 2004 12:19:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186567#M163930</guid>
      <dc:creator>Kenneth Platz</dc:creator>
      <dc:date>2004-02-09T12:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186568#M163931</link>
      <description>I am assuming that you only want the server name from the first entry in the file.  I hope I am reading this correctly.&lt;BR /&gt; &lt;BR /&gt;so my effort is this&lt;BR /&gt; &lt;BR /&gt;mailx -s `awk -F"." '{ print $3;exit }' /tmp/file' someone@some.domain</description>
      <pubDate>Mon, 09 Feb 2004 13:14:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186568#M163931</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-02-09T13:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186569#M163932</link>
      <description>Sorry, got one quote wrong! Should read&lt;BR /&gt; &lt;BR /&gt;mailx -s `awk -F"." '{ print $3;exit }' /tmp/file` someone@some.domain</description>
      <pubDate>Mon, 09 Feb 2004 13:15:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186569#M163932</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-02-09T13:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: parse out last bit of file name in scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186570#M163933</link>
      <description>Here's an even simpler way, let the shell do it for you:&lt;BR /&gt; &lt;BR /&gt;set -u&lt;BR /&gt;PATH=/usr/bin&lt;BR /&gt;MYEMAIL=somebody@someplace.com&lt;BR /&gt;cat /tmp/file | read MYFILE&lt;BR /&gt;do&lt;BR /&gt;  SERVER=${MYFILE##*.}&lt;BR /&gt;  mailx -s "$SERVER output file" &amp;lt; $MYEMAIL&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;The funny incantation ##*. says to return anything following the last appearance of the . character. For this construct, any number of dots may appear and only the text following the last dot will be returned. This is similar to ${some_full_pathname##*/} which returns just the name at the end of a bunch of slashes, like the basename command.</description>
      <pubDate>Mon, 09 Feb 2004 15:32:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-out-last-bit-of-file-name-in-scripts/m-p/3186570#M163933</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2004-02-09T15:32:04Z</dc:date>
    </item>
  </channel>
</rss>

