for循环浏览带有空格和一些特殊字符的文件 [英] for loop through files with spaces and some special characters

查看:108
本文介绍了for循环浏览带有空格和一些特殊字符的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在for循环中运行以下命令

I need to run the following command with a for loop

cat Locate\ Message.eml | ./locatePipe.php

我正在尝试以下操作,但是它似乎在文件名的第一个空格处中断了

I am trying the following however it seems to break on the first space in the file name

for i in $(find -name "*.eml"); do cat $i | ./locatePipe.php; done

如果重要的话,某些文件名包含"@",()",-",.","[]",'"

Some of the file names contain "@", "()", "-", ".", "[]", " ' " if that matters

推荐答案

我使用以下命令完成了此操作

I accomplished this using the following command

find -name '*.eml' | while read email; do cat "$email" | ./locatePipe.php; done

这篇关于for循环浏览带有空格和一些特殊字符的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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