looking for files and modify if size matches

hi there.

I'm at SunOS 5.9

At my new job i'm using UNIX, and it's my first time.

i'm trying to make a script for:

-find files with a name passed to it as parameter
-compare results with file size passed as parameter too
-when comparison's true --> move file
-if not--> make nothing

well, i'll have prevent too similer name-size files. but i can solve that later.

my trouble now is in spliting string with awk. i can't understand why it doesn't

work

name=`find $CLL_DAT -name "$1*" -print`;
lines=`awk 'END { print NR }' $name`
echo "$lines";
if [ "$lines" = "$2" ];
then
echo "here i'll do what i have";
else
echo "ERROR $name";
fi

this is working, but i need to expand string catched by find, into 'n' strings,

and make things for all of them.

name=`find $CLL_DAT -name "$1*" -print`;
awk '{n=split($name,names," ")}'#########################i don't know how to make work this split function
flag=0

for (( i = 0 ; i <= n; i++ ))
do
lines=`awk '{END { print NR }}' ${names[$i]}`
echo "$lines"
if [ "$lines" = "$2" ];
then
if ["$flag" = 1];
then
echo 'two files matches'
exit
fi

	flag=1
	name=$\{names[$i]\}
	echo 'matches'
else
	echo "don't matches"
fi

done

find $CLL_DAT -name "$1*" -print | \
while read name
  lines=`awk 'END { print NR }' $name`
  echo "$lines";
  if [ "$lines" = "$2" ];
  then
    echo "here i'll do what i have";
  else
    echo "ERROR $name";
  fi
done

thanks sb008, it really works!
thanks a lot

but i can't catch what really means | \

can you explain me briefly?
:slight_smile:

The "\" means that the line continues on the next line.

Actually it is:

find $CLL_DAT -name "$1*" -print | while read name

but for readability I start the while loop on the next line

similar:

ls | grep <something> | sort

could be written as

ls | \
grep <something> | \
sort

Same can be done with conditions

if [ <condition1> -o <condition2> -o <condition3> ]

if [ <condition1> -o \
<condition2> -o \
<condition3> ]