如何告诉find命令对文件名中的空格字符进行转义? [英] How to tell find command to escape space characters in file names?

查看:108
本文介绍了如何告诉find命令对文件名中的空格字符进行转义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单行的find命令,该命令递归检查并打印出在特定时间范围内创建的特定文件类型的大小,所有者和名称.但是结果是,给出文件名列,直到目录或文件名中的第一个空格字符为止.有什么想法可以在此单个命令中解决此问题,而无需在bash中编写任何循环?谢谢!

I have a single line find command, which recursively checks and prints out the size, owner and name of a specific file type which are created in a specific time frame. But in the result, the filename column is given until the first space character in the directory or file name. Any idea to fix this problem right in this single command without writing any loop in the bash? Thanks!

这是命令:

find /path/to/dist -type f -iname "*.png" -newermt 2015-01-01 ! -newermt 2016-12-31 -ls | sort -k5 | sort -k5 | awk '{print $5"\t"$7"\t"$11}'

推荐答案

非常感谢Arno的输入,以下行完成了这项工作.我使用exec( -exec ls -lh {} \; )使大小易于阅读:

Well thanks to Arno's input, the following line does the job. I used exec (-exec ls -lh {} \;) to make the size human readable:

find /Path/To/Dest/ -type f -iname "*.pdf" -newermt 2015-01-01 ! -newermt 2016-12-31 -exec ls -lh {} \; |sed 's/\\ /!!!/g' | sort -k5 | awk '{gsub("!!!"," ",$11);print $3"\t"$5"\t"$9}'

这篇关于如何告诉find命令对文件名中的空格字符进行转义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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