将'man grep'命令输出到文件中

时间:2021-11-06 03:52:23

I have practiced in using command line in CentOS6. I tried to create file, which content would be the output of command man grep. Also I used command man with col -b option to save file as Text-Only. All of this must be in one command. I tried to do like this:

我在CentOS6中使用过命令行。我试图创建文件,其内容将是命令man grep的输出。我还使用带有col -b选项的命令man将文件保存为纯文本。所有这一切都必须在一个命令中。我试着这样做:

grep man grep | col -b > output.txt

grep man grep | col -b> output.txt

But it didn't work.

但它没有用。

What is the proper way to save output of command man grep as Text-Only file with using option col -b?

使用选项col -b将命令man grep的输出保存为纯文本文件的正确方法是什么?

1 个解决方案

#1


4  

Don't you really need this:

你真的不需要这个:

man grep | col -b > output.txt

Why do you need to call grep in the first place?

为什么你需要首先调用grep?

Other, hacky way using grep:

其他,使用grep的hacky方式:

man grep | grep -v somephrasethatwontoccur | col -b > output.txt

But, truly, it makes no sense. grep -v looks for lines without the specified phrase.

但是,真的,这没有任何意义。 grep -v查找没有指定短语的行。

#1


4  

Don't you really need this:

你真的不需要这个:

man grep | col -b > output.txt

Why do you need to call grep in the first place?

为什么你需要首先调用grep?

Other, hacky way using grep:

其他,使用grep的hacky方式:

man grep | grep -v somephrasethatwontoccur | col -b > output.txt

But, truly, it makes no sense. grep -v looks for lines without the specified phrase.

但是,真的,这没有任何意义。 grep -v查找没有指定短语的行。