如何使用找到以空格显示目录? [英] How to use find on dirs with white spaces?

查看:163
本文介绍了如何使用找到以空格显示目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是一些奇怪的事情。

Here is something strange.

mkdir -p "1/2 3/4"
touch 1/2\ 3/4/file.jpg
for f in $(find . -type f -name \*jpg); do echo "${f}"; done

这将返回

./1/2
3/4/file.jpg

而不是

./1/2 3/4/file.jpg

我如何获得找到为preserve空格这样的文件路径是正确的?

How do I get find for preserve white spaces so the file path is correct?

推荐答案

它可以通过多种方式来实现,但我觉得它好得多做这种方式:

It can be done in several ways, but I find it much better to do it this way:

find . -type f -name \*.jpg | while read i ; do echo "Procesing $i..." ; done

这篇关于如何使用找到以空格显示目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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