linux - 将 cpp 文件中的注释写入 txt 文件
问题描述
我的朋友!我是 bash 的初学者,遇到了这样的问题。我需要在 cpp 文件中找到所有注释(包括多行)并将它们写入输出文件。我不知道如何选择评论。
#!/bin/bash
name1=$1 #solution.cpp
name2=$2 #out.txt
if [ ${name1: -4} == ".cpp" ]; then
cat solution.cpp | grep ^\//
else
echo "bad"
fi
解决方案
推荐阅读
- android - 如何在华为 P9 Eva-l09 上安装 TWRP
- php - 我如何在我所有页面的标题上登录后调用我的用户名 PHP mysql
- amazon-web-services - s3_out:无法在没有设置凭据的情况下签署请求
- python - Pytest mock.patch 请求 AttributeError:没有属性 'json'
- typescript - 为什么我不能在 const 数组中创建一种有效索引?
- c# - StaleElementException 单击接受条款
- reactjs - 显示来自 PapaParse 的数据
- leaflet - Leaflet - 是否可以防止 web 地图在首次加载时更改地图的缩放比例?
- kubernetes - 如何终止 Kubernetes 命名空间?
- python-3.7 - 我的 Python 程序中不断出现 ValueError