Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设您有以下脚本:
# My comment line 1 # My comment line 2 # My comment line 3 echo "My script" cd $MY_PATH ./anotherScript.ksh
有什么命令可以显示:
# My comment line 1 # My comment line 2 # My comment line 3
或者,我可以编写一个脚本来检测第一块评论。
谢谢
试试这个:
grep '^\#.*$' myscript.sh
您cat script.sh | grep ^\#只能显示这些行。
cat script.sh | grep ^\#
这会将您的文件输出到 grep 命令,该命令将使用“#”打印每一行
echo "My script" | grep "#"
编辑我很笨
你需要做的就是grep '#' file如果我这次理解正确。
grep '#' file