<?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: stacking or pop files script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206820#M714253</link>
    <description>While not strictly a true push/pop implementaion, there was nothing wrong with Marks's solution.  You'd just have to have the calling script know that the highest numbered suffix was the most recent.&lt;BR /&gt;&lt;BR /&gt;Anyway, how about this, since you asked for a shell script:&lt;BR /&gt;&lt;BR /&gt;****************&lt;BR /&gt;push.sh (stack)&lt;BR /&gt;****************&lt;BR /&gt;&lt;BR /&gt;typeset -i x&lt;BR /&gt;&lt;BR /&gt;if [ ! -f $1 ]&lt;BR /&gt;then&lt;BR /&gt;   exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for FILE in $(l -1r ${1}*)&lt;BR /&gt;do&lt;BR /&gt;   if [ $FILE != $1 ]&lt;BR /&gt;   then&lt;BR /&gt;      x=$(echo $FILE | awk -F. '{print $NF}')+1&lt;BR /&gt;   else&lt;BR /&gt;      x=1&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;   mv $FILE $1.$x&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;****************&lt;BR /&gt;pop.sh&lt;BR /&gt;****************&lt;BR /&gt;&lt;BR /&gt;typeset -i x&lt;BR /&gt;&lt;BR /&gt;if [ ! -f $1 ]&lt;BR /&gt;then&lt;BR /&gt;   exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for FILE in $(l -1 ${1}.*)&lt;BR /&gt;do&lt;BR /&gt;   x=$(echo $FILE | awk -F. '{print $NF}')-1&lt;BR /&gt;&lt;BR /&gt;   if [ $x -ne 0 ]&lt;BR /&gt;   then&lt;BR /&gt;      mv $FILE $1.$x&lt;BR /&gt;   else&lt;BR /&gt;      mv $FILE $1&lt;BR /&gt;   fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;****************&lt;BR /&gt;&lt;BR /&gt;The error checking is weak, but it will error out if there is no base name.  One thing I did provide for is multiple "." in a filename, so "toto.tmp" will work just as well as "toto".  Call the scripts as "stack.sh toto" and "pop.sh toto" and they'll do what you asked.  &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Seth</description>
    <pubDate>Wed, 03 Mar 2004 00:04:37 GMT</pubDate>
    <dc:creator>Seth Parker</dc:creator>
    <dc:date>2004-03-03T00:04:37Z</dc:date>
    <item>
      <title>stacking or pop files script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206816#M714249</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I look for a shell script&lt;BR /&gt;for "stacking" or "pop to" files in a directory , on HPUX server .&lt;BR /&gt;&lt;BR /&gt;Thanks .</description>
      <pubDate>Tue, 02 Mar 2004 09:42:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206816#M714249</guid>
      <dc:creator>iranzo</dc:creator>
      <dc:date>2004-03-02T09:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: stacking or pop files script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206817#M714250</link>
      <description>For me, you are going to have to explain what you mean by "stacking" or "pop to".</description>
      <pubDate>Tue, 02 Mar 2004 09:44:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206817#M714250</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-03-02T09:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: stacking or pop files script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206818#M714251</link>
      <description>sorry :&lt;BR /&gt;here a file : /tmp/toto&lt;BR /&gt;i receive another file "toto"&lt;BR /&gt;then the script "stacking" the file :&lt;BR /&gt;(rename the file )&lt;BR /&gt;now here 2 files /tmp/toto and /tmp/toto.1&lt;BR /&gt;&lt;BR /&gt;"pop to" is the inverse function .</description>
      <pubDate>Tue, 02 Mar 2004 09:59:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206818#M714251</guid>
      <dc:creator>iranzo</dc:creator>
      <dc:date>2004-03-02T09:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: stacking or pop files script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206819#M714252</link>
      <description>If I understand you correctly, this script will do it.  Save it as "stackpop"&lt;BR /&gt;&lt;BR /&gt;If you have a file "hello" "hello.1" and "hello.2" and run it as "stackpop stack hello" it will mv "hello" to "hello.3"&lt;BR /&gt; &lt;BR /&gt;If you the run it as "stackpop popto hello" it will move "hello.3" to "hello".&lt;BR /&gt; &lt;BR /&gt;It doesn't do any checking for errors and will happily overwrite things.  You might need to adjust it a bit.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;($action,$FILENAME)=@ARGV;&lt;BR /&gt;@files=glob "$FILENAME*";&lt;BR /&gt;($suffix)=(pop(@files)=~/$FILENAME.(\d+)/);&lt;BR /&gt;&lt;BR /&gt;eval($action);&lt;BR /&gt;&lt;BR /&gt;sub stack{&lt;BR /&gt;        $suffix++;&lt;BR /&gt;        `mv $FILENAME ${FILENAME}.$suffix`;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sub popto {&lt;BR /&gt;        `mv ${FILENAME}.$suffix $FILENAME`;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Mar 2004 10:54:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206819#M714252</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-03-02T10:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: stacking or pop files script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206820#M714253</link>
      <description>While not strictly a true push/pop implementaion, there was nothing wrong with Marks's solution.  You'd just have to have the calling script know that the highest numbered suffix was the most recent.&lt;BR /&gt;&lt;BR /&gt;Anyway, how about this, since you asked for a shell script:&lt;BR /&gt;&lt;BR /&gt;****************&lt;BR /&gt;push.sh (stack)&lt;BR /&gt;****************&lt;BR /&gt;&lt;BR /&gt;typeset -i x&lt;BR /&gt;&lt;BR /&gt;if [ ! -f $1 ]&lt;BR /&gt;then&lt;BR /&gt;   exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for FILE in $(l -1r ${1}*)&lt;BR /&gt;do&lt;BR /&gt;   if [ $FILE != $1 ]&lt;BR /&gt;   then&lt;BR /&gt;      x=$(echo $FILE | awk -F. '{print $NF}')+1&lt;BR /&gt;   else&lt;BR /&gt;      x=1&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;   mv $FILE $1.$x&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;****************&lt;BR /&gt;pop.sh&lt;BR /&gt;****************&lt;BR /&gt;&lt;BR /&gt;typeset -i x&lt;BR /&gt;&lt;BR /&gt;if [ ! -f $1 ]&lt;BR /&gt;then&lt;BR /&gt;   exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for FILE in $(l -1 ${1}.*)&lt;BR /&gt;do&lt;BR /&gt;   x=$(echo $FILE | awk -F. '{print $NF}')-1&lt;BR /&gt;&lt;BR /&gt;   if [ $x -ne 0 ]&lt;BR /&gt;   then&lt;BR /&gt;      mv $FILE $1.$x&lt;BR /&gt;   else&lt;BR /&gt;      mv $FILE $1&lt;BR /&gt;   fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;****************&lt;BR /&gt;&lt;BR /&gt;The error checking is weak, but it will error out if there is no base name.  One thing I did provide for is multiple "." in a filename, so "toto.tmp" will work just as well as "toto".  Call the scripts as "stack.sh toto" and "pop.sh toto" and they'll do what you asked.  &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Seth</description>
      <pubDate>Wed, 03 Mar 2004 00:04:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stacking-or-pop-files-script/m-p/3206820#M714253</guid>
      <dc:creator>Seth Parker</dc:creator>
      <dc:date>2004-03-03T00:04:37Z</dc:date>
    </item>
  </channel>
</rss>

