Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在文件中搜索键盘指定的扩展名。Shell脚本_Shell_Sh - Fatal编程技术网

在文件中搜索键盘指定的扩展名。Shell脚本

在文件中搜索键盘指定的扩展名。Shell脚本,shell,sh,Shell,Sh,我试图通过键盘指定文件扩展名,然后在当前目录中查找所有这些文件,但无法从变量中读取扩展名 echo Input file type: read EXT find . -name '*.{EXT}' 使用此脚本 #!/bin/bash echo -n "Input file type:" read EXT find . -type f -name "*.$EXT" 此脚本将搜索当前目录及其子目录中的文件。如果要优化此设置,可以使用maxdepth find . -maxdepth 1 -t

我试图通过键盘指定文件扩展名,然后在当前目录中查找所有这些文件,但无法从变量中读取扩展名

echo Input file type:
read EXT
find . -name '*.{EXT}'
使用此脚本

#!/bin/bash
echo -n "Input file type:"
read EXT
find .  -type f -name "*.$EXT"
此脚本将搜索当前目录及其子目录中的文件。如果要优化此设置,可以使用
maxdepth

find . -maxdepth 1  -type f -name "*.$EXT" 

-maxdepth X
:搜索当前目录以及所有子目录X depth。

就是这样!谢谢!