![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to prune multiple branches with find? | siegfried | UNIX for Dummies Questions & Answers | 1 | 04-11-2008 04:52 AM |
| Multiple conditions in find or ls stmts | mavsman | UNIX for Dummies Questions & Answers | 5 | 04-01-2008 05:57 PM |
| Find and replace a string in multiple files | pharos467 | UNIX for Dummies Questions & Answers | 2 | 11-05-2007 11:47 PM |
| find and FTP multiple files in Korn Shell | lambjam | UNIX for Dummies Questions & Answers | 2 | 08-13-2007 11:50 PM |
| find multiple file types and tar | manthasirisha | Shell Programming and Scripting | 9 | 03-21-2006 12:37 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
multiple -name in find
Hi,
Can I have multiple -name options when using find? I am using -> find . \( ! -name . -prune \) because I only want to search in the directory i'm in, not sub dirs. But i wan the specify the files I do search for. How can I do this? It is in part of this string for file in `find . \( ! -name . -prune \) \ -user cgi \ -mtime +$age \ -exec basename {} \;` Cheers in advance, |
|
||||
|
Hi Perderabo
This is great, I managed it to do what I was wanting from the command line but when I tried to put it into my script I was getting no files returned. I have taken the liberty to include my script, would you mind checking it over? Many thanks in advance HP_UX 11i Code:
#! /bin/ksh
control=/home/nhatch/CLEAN/clean_cntrl
dates=`date +%d%m%y_%H%M%S`
rmlog=/home/nhatch/CLEAN/removed_$dates.log
echo "Running $0" >> $rmlog
while read line
do
{
dir=`echo $line | cut -d, -f1`
age=`echo $line | cut -d, -f2`
ext=`echo $line | cut -d, -f3`
echo "\t Current search dir is $dir" >> $rmlog
echo $age
echo $ext
for file in `find $dir \( ! -name . -prune \) \( -name \*.$ext \) \
-user cgi \
-mtime +$age \
-exec basename {} \;`
do
rm $file
if [ $? -eq 0 ]
then
echo "File $file was deleted " >> $rmlog
else
echo "File $file was NOT deleted" >> $rmlog
fi
done
}
done < $control
/home/nhatch,5,DAT /home/admin,7,tmp |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|