How to store the result of find command in Shell program?
I want to store if found then result = 1 else result =0.
How to set the result ?
My code
result = $ (find . -name "doll" )
Can anybody help me?

ps.
tcsh in cygwin

hi,
yopu can make use of the following code. Hope this will work fine

#!/bin/tcsh
file=`find . -name "Doll"`
if [ -n "$file" ]
then
echo "Found"
result=1
else
echo "Not found"
result=0
fi
echo The result is $result

hi,
yopu can make use of the following code. Hope this will work fine

#!/bin/tcsh
file=`find . -name "Doll"`
if [ -n "$file" ]
then
echo "Found"
result=1
else
echo "Not found"
result=0
fi
echo The result is $result

Thanks for your reply.

Yet, I have error like , if : badly formed number in cygwin. Could you help me?
My code
#!/bin/tcsh
foreach file(*.*)
@ file=`find . -name "doll"`
if(-n "$file")then
echo "Found"
@ result = 1
else
echo "Not found"
@ result = 0
endif
echo The result is $result
end

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.