- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Remove all files except a file generated latest
Operating System - Linux
1753876
Members
7145
Online
108809
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
тАО04-06-2006 02:25 PM
тАО04-06-2006 02:25 PM
Remove all files except a file generated latest
Hi all.
It's been a nice day.
it is very sticky problem. can you give tips?
I'm going to remove oracle archive log file but generated lastet log file before file system is going to be full.
I'm going to post shell prg related job above,
and give me the solution which is fit for that job.
*Shell #1
#DELETING ARCHIVE LOG.
df -k > c
value=`awk '/\/arch_ispbs/ {print $3}' c`
str=`ps -e|grep save|awk '{print $4}'`
if [ $value -gt 4242880 -a -z "$str" ]; then
(/usr/bin/sh /d) > /dev/null 2>&1
fi
============================================
*Shell #2
touch /arch_ispbs/temp
save -s online -b oracle -l full /arch_ispbs
find /arch_ispbs ! -newer /arch_ispbs/temp |xargs rm
It's been a nice day.
it is very sticky problem. can you give tips?
I'm going to remove oracle archive log file but generated lastet log file before file system is going to be full.
I'm going to post shell prg related job above,
and give me the solution which is fit for that job.
*Shell #1
#DELETING ARCHIVE LOG.
df -k > c
value=`awk '/\/arch_ispbs/ {print $3}' c`
str=`ps -e|grep save|awk '{print $4}'`
if [ $value -gt 4242880 -a -z "$str" ]; then
(/usr/bin/sh /d) > /dev/null 2>&1
fi
============================================
*Shell #2
touch /arch_ispbs/temp
save -s online -b oracle -l full /arch_ispbs
find /arch_ispbs ! -newer /arch_ispbs/temp |xargs rm
- Tags:
- find
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2006 03:57 PM
тАО04-06-2006 03:57 PM
Re: Remove all files except a file generated latest
last_file=$(ls -1tr|tail -1)
echo "Removing all others files now"
find . -type f ! -name "${last_file}" -exec ll -d {} \;
ll ${last_file}
Check this first and then replce -exec ll -d {} with -exec rm {}
echo "Removing all others files now"
find . -type f ! -name "${last_file}" -exec ll -d {} \;
ll ${last_file}
Check this first and then replce -exec ll -d {} with -exec rm {}
There is no substitute to HARDWORK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2006 01:16 PM
тАО04-09-2006 01:16 PM
Re: Remove all files except a file generated latest
Thank you RAC .
I got your help and, editted the shell progrm like this.
#1. Save file before remove all file.
save -s online -b oracle -l full /arch_ispbs
#2. Generate latest file
last_file=`find /arch_ispbs |ls -1|tail -1`
#3. And then remove except latest file had above line
find /arch_ispbs ! -name $last_file|xargs rm
Owe to you, I have glad morning. Thank you
I got your help and, editted the shell progrm like this.
#1. Save file before remove all file.
save -s online -b oracle -l full /arch_ispbs
#2. Generate latest file
last_file=`find /arch_ispbs |ls -1|tail -1`
#3. And then remove except latest file had above line
find /arch_ispbs ! -name $last_file|xargs rm
Owe to you, I have glad morning. Thank you
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