Linux,打印文件中的所有行,而不是以 [英] Linux, Print all lines in a file, NOT starting with

查看:29
本文介绍了Linux,打印文件中的所有行,而不是以的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打印文件的内容,但我想忽略所有以 # 开头的行.我正在尝试使用 grep 和 awk 进行一些操作,但它一直在打印整个文件,或者只是打印以 # 开头的行.我你可以给我一个正确的方法,或者一个 grep/awk 命令,它会打印文件中不以 # 开头的任意行.

I would like to print the contents of a file, but all lines starting with # I want to ignore. I was trying some stuff with grep and awk, but it kept printing the whole file, or just printed the lines starting with #. I you could give me a push in the right way, or a grep/awk command that would print anyline in the file that does not start with #.

推荐答案

使用grep-v选项来否定条件:

Use the -v option of grep to negate the condition:

grep -v '^#' file

这篇关于Linux,打印文件中的所有行,而不是以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆