linux find:通过xargs移动文件

时间:2016-01-31 06:56:53

标签: linux find xargs

应该如何修复?我关注a tutorial,但收到此错误:

# this works great groups by year per month (1 2013, 2014, 2015)...
group1=df.groupby('Month','Year')

# works great to select by unit
group2=df.groupby('Unit', 'Month', 'Year')

# now i want the top 10 individuals in each group
# this doesn't work
month_indiv = group2[['Name', 'Count']]

*我对如何使用xargs执行此命令感兴趣!

3 个答案:

答案 0 :(得分:2)

您不需要使用xargsfind可以在匹配项上执行命令:

find ~/Desktop -name “*.jpg” -o -name “*.gif” -o -name “*.png” -exec mv \{\} ~/Pictures \;

您可以在-exec之后和转义分号\;之前发出命令。 \{\}将替换为匹配的文件名。

来自man find

  

-exec command ;

     

执行命令;如果返回0状态,则返回true。查找的所有后续参数都被视为命令的参数,直到由';'组成的参数为止遇到了。字符串“{}”将被当前文件名替换,该文件名将在命令的参数中出现,而不仅仅是在单独的参数中,就像在某些版本的find中一样。这两种结构都可能需要进行转义(使用'\')或引用以保护它们不被shell扩展。有关使用-exec选项的示例,请参阅“示例”部分。为每个匹配的文件运行一次指定的命令。该命令在起始目录中执行。围绕使用-exec操作存在不可避免的安全问题;你应该使用-execdir选项。

请注意,必须转义分号和{}。

答案 1 :(得分:2)

使用find和exec

$ find ~/Desktop -name "*.jpg" -exec mv '{}' /tmp/target/ \; -or -name "*.gif" -exec mv '{}' /tmp/target/ \; -or -name "*.png" -exec mv '{}' /tmp/target/ \;

使用xargs

$ find ~/Desktop -name "*.jpg" -or -name "*.gif" -or -name "*.png"  | xargs -I SRCFILE mv SRCFILE /tmp/target/

答案 2 :(得分:1)

我相信SSL_CTX_load_verify_locations(NULL, "keys"); 应为-target-directory,或--target-directory