🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Find command return type

scmuser created the topic: Find command return type
I am looking for following answer if anybody can help me out…

How to Return a message when a file is not found using find command? OR
Find command return type OR
when the file is not found i want it to return some value OR

tpatil replied the topic: Re: Find command return type
You can use exit code of find command to return the message.

e..g.

find . -name abc.txt > dev/null

if test $? -eq 0
then
echo "File found"
else
echo "File Not Found"
fi

Hope this helps…

rajeshkumar replied the topic: Re: Find command return type
Hi..

I guess following script will not work. The problem here is find command does always return true value no matter if find is available or not.

this is unique things in find command.

I feel we should go ahead in this way.

find . -name raj.txt > raj.txt
counter= `cat abc.txt | wc -l'

if [$counter -gt 0]
then
echo "File is found"
else
echo "File is not found"
fi

please let us your inputs on this
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

tpatil replied the topic: Re: Find command return type
Thanks Rajesh…You are right. I tried with my code. Find always retuns 0 though file not found.

Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x