<?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: Regarding string manipulation and ls in unix shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997050#M777955</link>
    <description>In my last response, line 6 should read &lt;BR /&gt;&lt;BR /&gt;$ print $str2&lt;BR /&gt;&lt;BR /&gt;Sorry,&lt;BR /&gt;Will</description>
    <pubDate>Tue, 15 Aug 2006 08:22:44 GMT</pubDate>
    <dc:creator>Will Couillard</dc:creator>
    <dc:date>2006-08-15T08:22:44Z</dc:date>
    <item>
      <title>Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997041#M777946</link>
      <description>I have a string &lt;BR /&gt;&lt;BR /&gt;1. str1=topasa1&lt;BR /&gt;i want to store it in another string str2 as&lt;BR /&gt;str2=asa1&lt;BR /&gt;How do i do it in unix shell script&lt;BR /&gt;&lt;BR /&gt;2. when i do a ls -ltr&lt;BR /&gt;ls -ltr&lt;BR /&gt;total 4&lt;BR /&gt;-rw-r--r--   1 scc        scc              8 Aug 14 00:46 test1&lt;BR /&gt;-rw-r--r--   1 scc        scc             17 Aug 14 00:47 test2&lt;BR /&gt;&lt;BR /&gt;i want the latest file of test* to be stored in a string  x1 how do i do it?&lt;BR /&gt;&lt;BR /&gt;x1=ls -ltr test* |...... &lt;BR /&gt;or &lt;BR /&gt;x1 = ls -lt test* |....&lt;BR /&gt;&lt;BR /&gt;how do i get the latest file test2 into x1&lt;BR /&gt;i need to get the output as x1=test2&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Aug 2006 01:52:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997041#M777946</guid>
      <dc:creator>vind123</dc:creator>
      <dc:date>2006-08-14T01:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997042#M777947</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;str2=`echo $str1 | cut -c3-`&lt;BR /&gt;&lt;BR /&gt;x1=`ls -tr test? | tail -1`&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Aug 2006 02:14:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997042#M777947</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-08-14T02:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997043#M777948</link>
      <description>Thanks a lot for the info. I am getting the below output when i run this command and i am getting the latestfile but i want remove the prefix "/home/users/scc/prodfiles/"  in the output and store the test2 in x2 variable. &lt;BR /&gt;&lt;BR /&gt;&amp;gt; ls -tr /home/users/fcc/prodfiles/test* | tail -1 &lt;BR /&gt;/home/users/fcc/prodfiles/test2&lt;BR /&gt;&lt;BR /&gt;I want the variable x2 to have test2 only&lt;BR /&gt;x2=`ls -tr /home/users/fcc/prodfiles/test* | tail -1`|.....&lt;BR /&gt;&lt;BR /&gt;what do i need to do for this one. Also the directory name,path might change. i want to filter the content after final "/" to get the file name&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Aug 2006 03:52:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997043#M777948</guid>
      <dc:creator>vind123</dc:creator>
      <dc:date>2006-08-14T03:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997044#M777949</link>
      <description>Hi,&lt;BR /&gt;please see:&lt;BR /&gt;man basename&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Aug 2006 04:07:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997044#M777949</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-08-14T04:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997045#M777950</link>
      <description>&lt;BR /&gt;&amp;gt;ls -tr /home/users/scc/prodfiles/test* | tail -1  &lt;BR /&gt;/home/users/fcc/prodfiles/test2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I did the below one but i didn't get the output.&lt;BR /&gt;&lt;BR /&gt;ls -tr /home/users/fcc/prodfiles/test* |tail -1 | basename&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Aug 2006 06:06:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997045#M777950</guid>
      <dc:creator>vind123</dc:creator>
      <dc:date>2006-08-14T06:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997046#M777951</link>
      <description>You can also just use your x1 variable as &lt;BR /&gt;&lt;BR /&gt;${x1##*/} &lt;BR /&gt;&lt;BR /&gt;that will drop off the path part of the variable. Useful if you want to preserve the path for some reason. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Aug 2006 06:48:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997046#M777951</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-08-14T06:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997047#M777952</link>
      <description>Hi,&lt;BR /&gt;x1=`ls -tr /home/users/fcc/prodfiles/test* |tail -1`&lt;BR /&gt;x1=`basename $x1`&lt;BR /&gt;&lt;BR /&gt;Also could you review your current threads after reading &lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Aug 2006 07:02:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997047#M777952</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-08-14T07:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997048#M777953</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;# x1=$(basename $(ls -1t /home/users/scc/prodfiles/test* | head -n 1))&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Mon, 14 Aug 2006 07:11:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997048#M777953</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-08-14T07:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997049#M777954</link>
      <description>For the first part of your post, if you always are removing the the first three characters of "str1" you can use:&lt;BR /&gt;&lt;BR /&gt;$ str1=topasa1&lt;BR /&gt;&lt;BR /&gt;$ str2=${str1#???}&lt;BR /&gt;&lt;BR /&gt;Then:&lt;BR /&gt;&lt;BR /&gt;$ print str2&lt;BR /&gt;&lt;BR /&gt;to see the result&lt;BR /&gt;&lt;BR /&gt;In this case each "?" removes antoher character from the left.  To remove from the right, user "%".&lt;BR /&gt;&lt;BR /&gt;Will</description>
      <pubDate>Tue, 15 Aug 2006 08:19:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997049#M777954</guid>
      <dc:creator>Will Couillard</dc:creator>
      <dc:date>2006-08-15T08:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997050#M777955</link>
      <description>In my last response, line 6 should read &lt;BR /&gt;&lt;BR /&gt;$ print $str2&lt;BR /&gt;&lt;BR /&gt;Sorry,&lt;BR /&gt;Will</description>
      <pubDate>Tue, 15 Aug 2006 08:22:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997050#M777955</guid>
      <dc:creator>Will Couillard</dc:creator>
      <dc:date>2006-08-15T08:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding string manipulation and ls in unix shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997051#M777956</link>
      <description>Thanks a lot for the info</description>
      <pubDate>Thu, 07 Sep 2006 02:41:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regarding-string-manipulation-and-ls-in-unix-shell-script/m-p/4997051#M777956</guid>
      <dc:creator>vind123</dc:creator>
      <dc:date>2006-09-07T02:41:12Z</dc:date>
    </item>
  </channel>
</rss>

