在Linux上查找名称中包含非法窗口字符的文件 [英] Find files with illegal windows characters in the name on Linux

查看:158
本文介绍了在Linux上查找名称中包含非法窗口字符的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Linux机器上有一个项目,其中包含文件,这些文件的字符在Windows中被认为是非法/保留的( http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx )。该项目有超过10,000文件跨几个文件夹,我会找出这些文件的路径。

I have a projects on my Linux box that contains file with characters that are considered illegal/reserved in Windows (http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx). The project has over 10,000 files across several folders and I'll to identify the path for these files.

我可以 find。 -name* \?*为每个非法/保留字符,但有没有一种更简单的方法来查找所有包含< > :/ \ |?*

I can find . -name "*\?*" for each of the illegal/reserved characters, but is there an easier way to find all files that contain < > : " / \ | ? *

一旦我确定了,我想从这些文件中删除所有这些字符。

Once I've identified, I would like to remove all such characters from each of these files.

推荐答案



This find one-liner should work for you:

find . -name "*[<>:\\|?*]*" -exec bash -c 'x="{}"; y="$(sed "s/[<>:\\|?*]\+/-/g" <<< "$x")" && mv "$x" "$y" ' \;

这篇关于在Linux上查找名称中包含非法窗口字符的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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