
同じことをless textfile | col
して成就しますか?cat textfile
man mysql | col -b > textfile
これも終わったのか気になりますman mysql > textfile
。
答え1
less
を使用してさまざまな種類の変換を実行できるため、これはかなり異なります$LESSOPEN
。
答え2
col
の出力で作業を実行できる場合とまったく同じではありませんless
。
ここで重要なのは、less
入力ファイルの出力がttyでない場合に出力にコピーされることです。で見ることができますless-451 - main.c - ライン 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);
}
cat file
したがって、可能なものと同じ操作を実行するには、次のようにします。
less file | grep ^