- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to make my script work?
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
11-19-2001 12:09 AM
11-19-2001 12:09 AM
Thanks,
$1=/tmp
for i in `find $1 -type f -mtime +1 -print`
do
echo $i
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:14 AM
11-19-2001 12:14 AM
Re: How to make my script work?
Do you mean
"cd /tmp"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:16 AM
11-19-2001 12:16 AM
Re: How to make my script work?
"1=/tmp", not "$1=/tmp".
suggest you use descriptive names like "mydir" instead of "1".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:17 AM
11-19-2001 12:17 AM
Re: How to make my script work?
$1 = first agrument
user DIR=/tmp
for i in `find $DIR .....`
do
action
done
Gideon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:21 AM
11-19-2001 12:21 AM
Re: How to make my script work?
I think you cannot assign a string variable to $1. $1 is used to invoke the second parameter in a command intruction. So for instance if you type ls -l, the -l will be stored in $1 by default.
You should have written:
a=/tmp
where a is any string you can imagine.
Remember to replace a by $a in the for loop.
HTH,
Vince
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:31 AM
11-19-2001 12:31 AM
Re: How to make my script work?
Two 'for' loops will do it. The first loop will deal with the directories to be cleaned in order, and will 'ls' the directory and file template to a temporary file, then the second loop for the contents of the temporary file (the file names).
Shaer and Enjoy! Fred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:36 AM
11-19-2001 12:36 AM
Re: How to make my script work?
You may want to use a while instead of a for, in case you need to process files with spaces in them. Also, find will work marginally quicker if you cd into the directory first:
dir=/tmp
cd $dir
find . -mtime +1 -type f -print | while read i
do
echo "$i"
done
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:39 AM
11-19-2001 12:39 AM
Re: How to make my script work?
try this:
dir=/tmp
for file in `find $dir -type f -mtime +1 -print`
do
echo $file
done
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:40 AM
11-19-2001 12:40 AM
Re: How to make my script work?
It seems in my script I cannot change $1 to point to other directory instead of the one given in the first parameter.
I want to issue "myscript /tmp" in the cronjob but at first I must test myscript on /tmp/zzg where there are temporary test files that can be used to test my script. That's why I purposely changed $1 to /tmp/zzg and pass it to "for i in `find $1 ..." after I have checked that $1 filesystem free space is less than 20%.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:45 AM
11-19-2001 12:45 AM
Re: How to make my script work?
In that case, at the top of your script, you should say:
dir=$1 # normal usage
dir=/tmp/zzg # test usage
for i in `find $dir...`
do
...
done
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 12:51 AM
11-19-2001 12:51 AM
Re: How to make my script work?
What exactly do you require your script to do?
As far as I can gleen you want to check free space in a lvol ??
If that is the case then this script from Andreas Voss will help.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2001 01:11 AM
11-19-2001 01:11 AM