我有各种文件 php html xml
,其中 copyright
通知包含在 top
中或在 2-3 行之后像这样顶
/**
* Copyright (c) 2014
* All rights reserved.
* bla bla many lines like this
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
现在我想从所有文件中删除所有文本。
如何使用 sed 删除
我只知道基本的 sed
但我不知道如何处理多行
最佳答案
$ cat file
1
2
/**
* Copyright (c) 2014
* All rights reserved.
* bla bla many lines like this
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
3
4
/* and here is another comment
* you presumably want to keep
*/
5
6
$ awk '/^\/\*/{c++} c!=1; /^ \*\//{c++}' file
1
2
3
4
/* and here is another comment
* you presumably want to keep
*/
5
6
关于linux - 如何用 sed 替换文件中的多行注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21215764/