用find -exec {} +跟踪参数 [英] Trailing arguments with find -exec {} +

查看:160
本文介绍了用find -exec {} +跟踪参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个尾随参数给 find -exec 选项的附加版本。 p>

  find。 -exec echo {} asd + 
#期望以下输出:
file1 file2 file3 [...] asd

不能用作 {} 必须是 + 之前的最后一个单词。 (奖金的问题:为什么没有实现那么简单的功能?)

什么是最简单的表达式来存档,可以处理空格和特殊字符的文件名? POSIX一致性是一件很好的事,但它可以和Linux一起工作。

。 -exec sh -c'echo$ @asd_ {} +


I want to add a trailing argument to the appending version of the-exec option of find.

find . -exec echo {} asd +
# expecting the following output:
file1 file2 file3 [...] asd

Does not work as {} must be the last word before +. (Bonus question: Why was that trivial looking feature not implemented?)

What is the simplest expression to archive this, that can handle filenames with spaces and special characters? POSIX conformance would be a nice to have but it is sufficient if it works with Linux.

解决方案

find . -exec sh -c 'echo "$@" asd' _ {} +

这篇关于用find -exec {} +跟踪参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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