I just need to search for a specific directory that can be anywhere is there a way to run this command until the first match? Thanx!
Im now ussing
find / -noleaf -name 'experiment' -type d | wc -l
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As Rudolf Mühlbauer mentions, the
-quitoption tellsfindto quit. The man page example is thatfind /tmp/foo /tmp/bar -print -quitwill print only
/tmp/foo.Slightly more generally,
findmay be the wrong tool for what you want to do. Seeman locate. For example, on my system,locate experiment | head -3produces
while
locate -r 'experimental..$'produces (with 6 lines snipped for brevity)As noted in ShpielMeister’s comment, the
locatedatabase is updated only periodically (eg, daily on Ubuntu Linux systems). When new files are a concern, saysudo updatedb, which in a second or two of work will update the database. Also see: ioflood.com blog about locate command