如何使用“查找"在名称中包含空格的目录中搜索文件? [英] How can I search for files in directories that contain spaces in names, using "find"?
本文介绍了如何使用“查找"在名称中包含空格的目录中搜索文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用find
在名称中包含空格的目录中搜索文件?
我使用脚本
How can I search for files in directories that contain spaces in names, using find
?
i use script
#!/bin/bash
for i in `find "/tmp/1/" -iname "*.txt" | sed 's/[0-9A-Za-z]*\.txt//g'`
do
for j in `ls "$i" | grep sh | sed 's/\.txt//g'`
do
find "/tmp/2/" -iname "$j.sh" -exec cp {} "$i" \;
done
done
但是名称中包含空格的文件和目录不会被处理吗?
but the files and directories that contain spaces in names are not processed?
推荐答案
这将捕获其中包含空格的所有文件
This will grab all the files that have spaces in them
$ls
more space nospace stillnospace this is space
$find -type f -name "* *"
./this is space
./more space
这篇关于如何使用“查找"在名称中包含空格的目录中搜索文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文