- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: scripting help
Operating System - HP-UX
1753494
Members
5223
Online
108794
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО11-22-2004 09:08 AM
тАО11-22-2004 09:08 AM
scripting help
Whenever a file is put on the server it goes to the root /interface/Exel and the file type is xxxx.INT.
If it is larger than 1kb, i want to rename it to exel887_$(%Y%m%H%M%S).txt.
If it is less than 1kb, i want to rename it to exel997__$(%Y%m%H%M%S.txt.
I would like to make it as looping script because there are more than 2 INT extension files in the directory.
If it is larger than 1kb, i want to rename it to exel887_$(%Y%m%H%M%S).txt.
If it is less than 1kb, i want to rename it to exel997__$(%Y%m%H%M%S.txt.
I would like to make it as looping script because there are more than 2 INT extension files in the directory.
brian lee
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2004 09:41 AM
тАО11-22-2004 09:41 AM
Re: scripting help
Hi Brian,
Test this before you go for it. Hopefully I understood your requirement.
LIMIT=1
DIR=/interface/Exel
DATE=$(date +%Y%m%H%M%S)
ls -1 $DIR/*.INT|while read ENTRY
do
FILE=$(basename "$ENTRY")
SZ=$(du -ks "$ENTRY"|awk '{print $1}')
if [[ $SZ -ge $LIMIT ]]
then
mv $DIR/"$FILE" $DIR/"${FILE}_exel887_${DATE}.txt"
else
mv $DIR/"$FILE" $DIR/"${FILE}_exel997_${DATE}.txt"
fi
done
-Sri
Test this before you go for it. Hopefully I understood your requirement.
LIMIT=1
DIR=/interface/Exel
DATE=$(date +%Y%m%H%M%S)
ls -1 $DIR/*.INT|while read ENTRY
do
FILE=$(basename "$ENTRY")
SZ=$(du -ks "$ENTRY"|awk '{print $1}')
if [[ $SZ -ge $LIMIT ]]
then
mv $DIR/"$FILE" $DIR/"${FILE}_exel887_${DATE}.txt"
else
mv $DIR/"$FILE" $DIR/"${FILE}_exel997_${DATE}.txt"
fi
done
-Sri
You may be disappointed if you fail, but you are doomed if you don't try
- Tags:
- mv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2004 09:51 AM
тАО11-22-2004 09:51 AM
Re: scripting help
The first thing you better put into your script is a delay loop to at least check the size of the file twice because it may be growing at the very moment you determine its size.
If I were doing this, I would make use of Perl's stat and localtime functions.
You also need to clarify whether you want the current time or the file's last modication time. This is an easy script but writing it for you does you no favors. You need to do a bit on your own first.
If I were doing this, I would make use of Perl's stat and localtime functions.
You also need to clarify whether you want the current time or the file's last modication time. This is an easy script but writing it for you does you no favors. You need to do a bit on your own first.
If it ain't broke, I can fix that.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2004 09:54 AM
тАО11-22-2004 09:54 AM
Re: scripting help
My point is about not doing it for you is appropriate because you ranked yourself in your Profile as an expert in this area.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP