shell -c
个人博客地址:shell -c | 一张假钞的真实世界
shell -c {string}
:表示命令从-c
后的字符串读取。在需要使用管道或者重定向需要sudo时很有用,如下:
$ sudo find ../*/exportFiles -mtime +15 -name "*" | xargs -I {} rm -rf {}
rm: cannot remove `i_20201108_CONTENTINFO_xy_001.dat': Permission denied
按照以下方式处理即可:
$ sudo sh -c 'find ../*/exportFiles -mtime +15 -name "*" | xargs -I {} rm -rf {}'