I would like to do this in Bash:
- in the current directory, find the first folder that contains "foo" in the name
I've been playing around with the find command, but a little confused. Any suggestions?
I would like to do this in Bash:
I've been playing around with the find command, but a little confused. Any suggestions?
You can use the
-quit
option offind
:for example:
or (For the better shell solution see Adrian Frühwirth's answer)
or
Edited head -n1 based on @ hek2mgl comment
Next based on @chepner's comments
or
This is better than the other shell solution provided because
${dir}
will be empty)=~
operator (if you need this depends on your pattern)find
)