Do less textfile | col
and cat textfile
accomplish the same thing?
I wonder if man mysql | col -b > textfile
and man mysql > textfile
do the same?
That's completely different, since less
may do various kinds of transformation, e.g. via $LESSOPEN
.
It's not quite the same, since when col
can do something with output from less
.
The important point here, less
will copy input file to output if its output is not a tty. You can see in less-451 - main.c - line 222:
/*
* Set up terminal, etc.
*/
if (!is_tty)
{
/*
* Output is not a tty.
* Just copy the input file(s) to output.
*/
SET_BINARY(1);
if (nifile() == 0)
{
if (edit_stdin() == 0)
cat_file();
} else if (edit_first() == 0)
{
do {
cat_file();
} while (edit_next(1) == 0);
}
quit(QUIT_OK);
}
So, to do the same as cat file
, you can:
less file | grep ^
less
doesn't do anything special, your less file | grep .
example is wrong, as grep .
will/may filter out lines that do not contain valid characters.
col -b
that they're different, in the sense, that if there are any backspaces within the output, thecol -b
will strip them away.