Hi All,
working on AIX 5.3.
Requirement is:
Shell script in ksh to check if any file exists in 4 folders as below:
- /FILE/INB/INT1
- /FILE/INB/INT2
- /FILE/INB/INT3
- /FILE/INB/INT4
Thanks a lot for your time!
a1_win.
Hi All,
working on AIX 5.3.
Requirement is:
Shell script in ksh to check if any file exists in 4 folders as below:
Thanks a lot for your time!
a1_win.
Here is one way
#!/bin/ksh
#
for dir in 1 2 3 4
do
cnt=$(ls /FILE/INB/INT{dir} | wc -l)
if [[ $cnt -ne 0 ]] ; then
echo "no file in /FILE/INB/INT{dir}"
fi;
done;
filecount()
{
[ -e "$1" ] && numfiles=$# || numfiles=0
}
for dir in /FILE/INB/INT1 /FILE/INB/INT2 /FILE/INB/INT3 /FILE/INB/INT4
do
filecount "$dir"/*
if [ $numfiles -gt 0 ]
then
printf "%d files in %s\n" "$numfiles" "$dir"
fi
done
Not sure how find behaves in AIX (or if this counts as a "script"), but...
RESULTS = `find ./FILE/INB/INT[1-4] -type f | wc -l`
if [ $RESULTS gt 0 ] ; then
echo "There are $RESULTS files"
fi