我知道我有一个文件。
我知道这个文件是 Hello.txt,或 HeLLo.txt,或 HEllo.txt,或其他大小写变体
所以我可以使用以下方法找到这个文件:
find . -iname hello.txt
它找到了。
如何将真实姓名(“HelLO.txt”)放入 linux 变量中?
最佳答案
var=`find . -iname hello.txt | head -n1 | sed 's/.*\///g'`
应该做你想做的。
关于linux - 查找文件(不区分大小写)并在变量中获取真实文件名(区分大小写),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17493390/