使用bash查找包含字符串的第一个文件夹名称 [英] Use bash to find first folder name that contains a string

查看:147
本文介绍了使用bash查找包含字符串的第一个文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Bash中做到这一点:在当前目录中找到第一个包含foo的文件夹名称


我一直在玩find命令,但有点困惑。任何建议?

解决方案

您可以使用 -quit code> find :

  find< dir> -maxdepth 1 -type d -name'* foo *'-print -quit 


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?

解决方案

You can use the -quit option of find:

find <dir> -maxdepth 1 -type d -name '*foo*' -print -quit

这篇关于使用bash查找包含字符串的第一个文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆