- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Any help for this script appreciated
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
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
тАО07-06-2005 02:16 PM
тАО07-06-2005 02:16 PM
#!/usr/bin/sh
find /tmp -mtime +240 -exec rm {} \;
Here i have to pass the days value interactively. please help me to solve this.
Rajesh
Solved! Go to Solution.
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 02:43 PM
тАО07-06-2005 02:43 PM
SolutionI am not an expert in scripting but it should work.
===========================================
#!/usr/bin/sh
read var1
echo $var1
find /tmp -mtime +$var1 -exec rm {} \;
exit
===========================================
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 03:40 PM
тАО07-06-2005 03:40 PM
Re: Any help for this script appreciated
I think what Devender has suggested should be fine. Since you have mentioned you want to pass the value interactively, here is a modification
#!/usr/bin/sh
echo "Please enter the number of days: \c"
read var1
echo "files older than $var1 days will be deleted "
find /tmp -mtime +$var1 -exec rm {} \;
exit
thanks
DP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 03:47 PM
тАО07-06-2005 03:47 PM
Re: Any help for this script appreciated
#!/usr/bin/sh
echo "Please enter the age of files you want to delete in days:"
read DAYS
find /tmp -mtime +${DAYS} -type f -exec ls -ld {} \;
echo "Are you sure you want to delete all of these files?"
read ANSWER
if [[ ${ANSWER} = "Y" -o ${ANSWER} = "y" ]] ; then
find /tmp -mtime +${DAYS} -type f -print -exec rm -f {} \;
fi
This script will first list the files you want to delete and then prompt you to make sure you want to delete them. If you answer with anything other than Y or y, then it won't delete the files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 04:38 PM
тАО07-06-2005 04:38 PM
Re: Any help for this script appreciated
That's why you need to pass them interactively.
Just add a while loop in Patrick's script
echo "Continue"
read choice
While ($choice='y')
Patric's script
read choice
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 04:57 PM
тАО07-06-2005 04:57 PM
Re: Any help for this script appreciated
#find /tmp -mtime +${FINDDAY} -exec rm {} \;
If you want to change it then,
# export FINDDAY=100
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-07-2005 01:49 AM
тАО07-07-2005 01:49 AM
Re: Any help for this script appreciated
#!/usr/bin/sh
PROG=${0}
typeset -i STAT=255
if [[ ${#} -ge 1 ]]
then
typeset -i DAYS=${1}
shift
find /tmp -mtime +${DAYS} -exec rm \;
STAT=${?}
else
echo "Usage: ${PROG} requires 1 arg." >&2
fi
exit ${STAT}
You would use it like this:
myscript.sh 100
If you like, you could write another little script that prompts for the value and then pass this value into myscript.sh.