- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help in 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
Discussions
Discussions
Discussions
Forums
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
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
тАО08-12-2008 04:53 AM
тАО08-12-2008 04:53 AM
Every time the script runs, it makes a directory naming config.mmddyy and stores configuration information in it. I have made a script upto this point.
Now I want to keep only the latest 5 directories and delete the diectories other than them with the information in them .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2008 05:17 AM
тАО08-12-2008 05:17 AM
Solutionfind /config.* - type d -mtime +5 |while read list
do
rm -r $list
done
(I would be carefull about rm -r, maybe even build a file list and rm $list then rmdir the directory.) If your list returns just "/" you will be bumming.
If you try to use each name mmddyy + 5 days you will run into the always difficult roll at EOM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2008 05:20 AM
тАО08-12-2008 05:20 AM
Re: Help in script
# ls -lt|grep ^d|tail +5|awk '{print $NF}'|xargs rmdir
...assuming that the directories are ones immediately beneath the current working directory and that they are empty. If they are not empty, but you want to delete them and their contents, then:
# ls -lt|grep ^d|tail +5|awk '{print $NF}'|xargs rm -rf
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2008 05:51 AM
тАО08-12-2008 05:51 AM
Re: Help in script
If you used a naming scheme like yymmdd
instead of mmddyy, it would be easier to sort
the names chronologically, so techniques like
piping "ls" output into "head" or "tail"
could do useful things (easily).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2008 03:18 AM
тАО08-13-2008 03:18 AM
Re: Help in script
To remove what the symlink points to, you can use: rm -rf symlink01/
To shuffle them down, you would have to parse the output of ll(1) to get the link target.