[英]Sed Delete first line of every file that ends has .jsx extension
So in React 0.12 having /** @jsx React.DOM */
at the top of all jsx files is no longer necessary. 因此,在React 0.12中,不再需要在所有jsx文件的顶部都带有
/** @jsx React.DOM */
。 A library that I'm using actually throws an error when it sees the /** @jsx React.DOM */
line that exists at the top of every jsx file. 当我使用的库看到每个jsx文件顶部存在的
/** @jsx React.DOM */
行时,实际上会引发错误。
So I wanted to know if there was a quick way using sed to remove this line from every file within a directory. 因此,我想知道是否存在使用sed从目录中每个文件中删除此行的快速方法。
Should I just remove line 1, or is there a way for me to pattern match, and verify that it's at the top? 我应该只删除第1行,还是我有办法进行模式匹配,并确认它在顶部? Also how would one recursively remove it from all files within a directory, and it's subdirectories?
另外,如何将其从目录及其子目录中的所有文件中递归地删除?
Thank you! 谢谢!
Yes, it's simple with the help of find
. 是的,在
find
的帮助下很简单。 The following command lines the first line of all *.jsx files: 以下命令在所有* .jsx文件的第一行中进行命令行:
find /path/to/files -name '*.jsx' -exec sed -i '1d' {} \;
This command removes lines containing that certain comment: 此命令删除包含该注释的行:
find /path/to/files -name '*.jsx' -exec sed -i '/^\/\*\* @jsx React\.DOM \*\/$/d' {} \;
Make a backup of your files before issuing that commands since they modify the files in place. 在发出命令之前,请先对其文件进行备份,因为它们会在适当位置修改文件。 Better safe than sorry.
安全胜过遗憾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.