- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- stacking or pop files script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2004 01:42 AM
03-02-2004 01:42 AM
stacking or pop files script
I look for a shell script
for "stacking" or "pop to" files in a directory , on HPUX server .
Thanks .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2004 01:44 AM
03-02-2004 01:44 AM
Re: stacking or pop files script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2004 01:59 AM
03-02-2004 01:59 AM
Re: stacking or pop files script
here a file : /tmp/toto
i receive another file "toto"
then the script "stacking" the file :
(rename the file )
now here 2 files /tmp/toto and /tmp/toto.1
"pop to" is the inverse function .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2004 02:54 AM
03-02-2004 02:54 AM
Re: stacking or pop files script
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"
If you the run it as "stackpop popto hello" it will move "hello.3" to "hello".
It doesn't do any checking for errors and will happily overwrite things. You might need to adjust it a bit.
#!/usr/bin/perl
($action,$FILENAME)=@ARGV;
@files=glob "$FILENAME*";
($suffix)=(pop(@files)=~/$FILENAME.(\d+)/);
eval($action);
sub stack{
$suffix++;
`mv $FILENAME ${FILENAME}.$suffix`;
}
sub popto {
`mv ${FILENAME}.$suffix $FILENAME`;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2004 04:04 PM
03-02-2004 04:04 PM
Re: stacking or pop files script
Anyway, how about this, since you asked for a shell script:
****************
push.sh (stack)
****************
typeset -i x
if [ ! -f $1 ]
then
exit 1
fi
for FILE in $(l -1r ${1}*)
do
if [ $FILE != $1 ]
then
x=$(echo $FILE | awk -F. '{print $NF}')+1
else
x=1
fi
mv $FILE $1.$x
done
****************
pop.sh
****************
typeset -i x
if [ ! -f $1 ]
then
exit 1
fi
for FILE in $(l -1 ${1}.*)
do
x=$(echo $FILE | awk -F. '{print $NF}')-1
if [ $x -ne 0 ]
then
mv $FILE $1.$x
else
mv $FILE $1
fi
done
****************
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.
Regards,
Seth