- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script to sequence log files
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
06-12-2003 02:37 AM
06-12-2003 02:37 AM
script to sequence log files
I'm trying to simplify a script I have for sequencing files, maybe someone has one already or advice on the best way to go about it?
The script applies sequence numbers to log files each day from 001->100.
File names are of the format
Any help much appreciated,
Vin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 03:02 AM
06-12-2003 03:02 AM
Re: script to sequence log files
Try something like this (no hpux on hands)
COUNT=1
while $COUNT < 101
do
DATE=$( date +%a%I )
touch /dir/$COUNT$DATE.log
let COUNT=COUNT+1
done
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 03:08 AM
06-12-2003 03:08 AM
Re: script to sequence log files
Assuming that your files were named like '20030612_hhmmss' something like this would do:
#!/usr/bin/sh
typeset -i N
typeset D=`date +%Y%m%d`
cd /tmp
for F in `ls f${D}*.log`
do
(( N=N+1 ))
mv ${F} ${N}${F}
done
exit 0
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 03:24 AM
06-12-2003 03:24 AM
Re: script to sequence log files
first of all I would create 100 empty files (001.log to 100.log). then it would be easy to run the script every day :
#!/usr/bin/sh
I=1
while [ $I -le 100 ]
do
touch $(printf "%3.3d.log" $I)
I=$((I+1))
sleep 1
done
without sleep, it seems that files could have creation time in the wrong order. It's run only once, so ...
Then, you can run this script every day. Argument should be the new log file, or you can directly get it from the script using a ls pattern or a date :
#!/usr/bin/sh
TARGET=$(ls -rt [01][0-9]*.log | line)
mv $1 $(echo $TARGET | cut -c1-3)_$1
rm $TARGET
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 12:36 AM
06-13-2003 12:36 AM
Re: script to sequence log files
ie:
typeset -Z3 name
a=1
echo $a
001
This will simplify the filenaming side of things.