0

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

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by diddle
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.