问题
I was trying to find a line ending with -s
with the following command but got warnings:
$ man gcc | grep '\-s$'
<standard input>:4808: warning [p 54, 13.2i]: can't break line
$ man gcc | egrep '\-s$'
<standard input>:4808: warning [p 54, 13.2i]: can't break line
Below is my development environment:
$ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u1 (2015-12-14) x86_64 GNU/Linux
$ gcc --version
gcc (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
回答1:
Normally man
formats the content to match the width of the terminal. You redirect it's output to a pipe, which has no "screen width", therefore it formats using the default width of 80 chars.
Some man pages has tables that are more than 80 chars wide, so you get this "can't break line" warning.
Try this:
$ MANWIDTH=160 man gcc | grep '\-s$'
来源:https://stackoverflow.com/questions/34621046/why-is-this-cant-break-line-warning-from-grep-of-gcc-man-page