Hi everybody!
it's great to be here since this is my first post.
touch /base/oracle/FRA/XMUT00/RMAN_FLAG
touch /base/oracle/FRA/XRLL00/RMAN_FLAG
find directory name containing RMAN_FLAG :
$ find /base/oracle/FRA -name RMAN_FLAG -print|xargs -n1 dirname |sort -u
/base/oracle/FRA/XMUT00
/base/oracle/FRA/XRLL00
find all file named *.arc :
$ find /base/oracle/FRA -name "*.arc" -print
/base/oracle/FRA/XARS00/XARS00arch6563.arc
/base/oracle/FRA/XARS00/XARS00arch6562.arc
/base/oracle/FRA/XARS00/XARS00arch6559.arc
/base/oracle/FRA/XARS00/XARS00arch6560.arc
/base/oracle/FRA/XARS00/XARS00arch6561.arc
/base/oracle/FRA/XBIO00/XBIO00arch286.arc
/base/oracle/FRA/XMUT00/XMUT00arch3624.arc
/base/oracle/FRA/XMUT00/XMUT00arch3616.arc
/base/oracle/FRA/XMUT00/XMUT00arch3613.arc
/base/oracle/FRA/XMUT00/XMUT00arch3621.arc
/base/oracle/FRA/XMUT00/XMUT00arch3626.arc
/base/oracle/FRA/XRLL00/XRLL00arch5199.arc
/base/oracle/FRA/XRLL00/XRLL00arch5200.arc
/base/oracle/FRA/XRLL00/XRLL00arch5201.arc
/base/oracle/FRA/XRLL00/XRLL00arch5202.arc
I want to remove all *.arc files execpt those found in directories where RMAN_FLAG is present
I tried :
EXCLU=$(find /base/oracle/FRA -name RMAN_FLAG -print|xargs -n1 dirname |sort -u)
for file in $(find /base/oracle/FRA -name "*.arc" -print|grep -v ${EXCLU})
do
rm $file
done
but grep does not work with multiple values (I know perl grep function accept a list of values but shell grep don't )
any hints? using sed and/or maybe awk?
I'm on HPUX standard grep/awk/sed (not gnu)
thanks
Darwin1
December 5, 2006, 10:01am
2
This works for me:
#!/bin/ksh
for f in $( find /base/oracle/FRA -name *.arc -print )
do
if [ ! -f "$( echo $f | sed 's/\/[^\/]*$/\/RMAN_FLAG/' )" ]; then
rm -f $f
fi
done
I've tested it with ksh, maybe some small modifications are needed for other shells.
Darwin
thanks that's exactly what I needed
anbu23
December 6, 2006, 1:18am
4
jolan_louve:
Hi everybody!
it's great to be here since this is my first post.
touch /base/oracle/FRA/XMUT00/RMAN_FLAG
touch /base/oracle/FRA/XRLL00/RMAN_FLAG
find directory name containing RMAN_FLAG :
$ find /base/oracle/FRA -name RMAN_FLAG -print|xargs -n1 dirname |sort -u
/base/oracle/FRA/XMUT00
/base/oracle/FRA/XRLL00
find all file named *.arc :
$ find /base/oracle/FRA -name "*.arc" -print
/base/oracle/FRA/XARS00/XARS00arch6563.arc
/base/oracle/FRA/XARS00/XARS00arch6562.arc
/base/oracle/FRA/XARS00/XARS00arch6559.arc
/base/oracle/FRA/XARS00/XARS00arch6560.arc
/base/oracle/FRA/XARS00/XARS00arch6561.arc
/base/oracle/FRA/XBIO00/XBIO00arch286.arc
/base/oracle/FRA/XMUT00/XMUT00arch3624.arc
/base/oracle/FRA/XMUT00/XMUT00arch3616.arc
/base/oracle/FRA/XMUT00/XMUT00arch3613.arc
/base/oracle/FRA/XMUT00/XMUT00arch3621.arc
/base/oracle/FRA/XMUT00/XMUT00arch3626.arc
/base/oracle/FRA/XRLL00/XRLL00arch5199.arc
/base/oracle/FRA/XRLL00/XRLL00arch5200.arc
/base/oracle/FRA/XRLL00/XRLL00arch5201.arc
/base/oracle/FRA/XRLL00/XRLL00arch5202.arc
I want to remove all *.arc files execpt those found in directories where RMAN_FLAG is present
I tried :
EXCLU=$(find /base/oracle/FRA -name RMAN_FLAG -print|xargs -n1 dirname |sort -u)
for file in $(find /base/oracle/FRA -name "*.arc" -print|grep -v ${EXCLU})
do
rm $file
done
but grep does not work with multiple values (I know perl grep function accept a list of values but shell grep don't )
any hints? using sed and/or maybe awk?
I'm on HPUX standard grep/awk/sed (not gnu)
thanks
find /base/oracle/FRA -name RMAN_FLAG -print|xargs -n1 dirname |sort -u > tmp
for file in $(find /base/oracle/FRA -name "*.arc" -print|grep -v -f tmp)
Do the above modification to make grep work