sed -i 's/\/\/[^"]*//' $file #删除以C语言中注释只在一行的行 sed -i 's/\/\*.*\*\///' $file #Delete the lines between /* and */ #删除C语言中注释跨行的情况 sed -i '/^[ \t]*\/\*/,/.*\*\//d' $file } function del_comment() { #$Dir=`pwd` for file in `...
Linux操作系统中去掉各类文件中的注释这个功能比较常用,通常用在查看一个较长的文件,又不想看注释的情况。通常这些文件包括C语言编写的*.c、*.h文件、cpp文件、*.xml文件、*.sh shell脚本文件、*.ini *.conf配置文件、*.php *.py *.pl等编程语言编写的文件以及无扩展名的一些可执行文件等。 实现这个功能并...
set -e conf=$1 current_path=$(cd $(dirname $0); pwd) if [ ! -f "$conf" ]; then echo "the file $conf is not exesit!,please check it" exit 101 fi while read line do echo $line if ( echo ${line} |grep -q "//" ); then echo $line newline=$(echo $line|cut -b 3-...
方法1、使用grep -v "^#" 来去掉注释行,其中:-v 表示取反 ^# 表示注解行 grep -v "^#" /etc/vsftpd/vsftpd.conf (使用“>”来重写配置文件也是可以的) 方法2、连同空行一起去掉,使用管道符。(^$表示空行 ) grep -v "^#" httpd.conf | grep -v "^$" >> vsftpd.conf 以上用...
需要金币:*** 金币(10金币=人民币1元) Linux中使用Shell脚本去掉源码注释的方法.pdf 关闭预览 想预览更多内容,点击免费在线预览全文 免费在线预览全文 Linux中使用Shell脚本去掉源码注释的方法|||Linux中使用Shell脚本去掉源码注释的方法|||Linux中使用Shell脚本去掉源码注释的方法 下载...
试试这样: sed '/^$/d' input | awk '{print $0"\n"}' >output处理input文件。 首先用sed去掉所有空行,然后通过awk在逐行打印时再加上一个空行。 结果保存到output文件中。
Linux操作系统中去掉各类文件中的注释这个功能比较常用,通常用在查看一个较长的文件,又不想看注释的情况。通常这些文件包括C语言编写的*.c、*.h文件、cpp文件、*.xml文件、*.sh shell脚本文件、*.ini *.conf配置文件、*.php *.py *.pl等编程语言编写的文件以及无扩展名的一些可执行文件等。
/bin/sh -f function del_comment_file() { #C++模式注释的删除。 #Delete the line begins with // #首先删除//在行首的行 sed -i ’/^[ \t]*\/\//d’ $file #Delete the line ends with // #注意已经除去了 //在行首的情况,下面匹配除去URL的//部分,因为代码中有一部分中有 #URL,形如...
/bin/sh -ffunction del_comment_file(){#C++模式注释的删除。#Delete the line begins with //#首先删除//在行首的行 sed -i ’/^[ \t]*\/\//d’ $file#Delete the line ends with //#注意已经除去了 //在行首的情况,下面匹配除去URL的//部分,因为代码中有一部分中有#URL,形如fun("ftp://"...