lessのすべての行をファイルに書き込むには?

lessのすべての行をファイルに書き込むには?

コマンドをパイプで接続し、lessそのコマンドの出力をファイルに保存しようとしています。どうすればいいですか?

この場合はを使用したくありません。tee使用を忘れた場合は、長期実行コマンドを再実行する必要がないように、lessから直接ソリューションを使用してくださいtee

この質問はこの質問に似ています。唯一の違いは、サブセットではなくすべての行を保存したいということです。lessからファイルに行を書く

ベストアンサー1

Fromにlessを入力し、s保存するファイル名を入力してを入力しますEnter。そのページ
から:manCOMMANDS

s filename
      Save the input to a file.  This only works if the input is a pipe, not an ordinary file.

manまた、ページには、特定のインストールによってはこのsコマンドを使用できない可能性があることが示されています。この場合、次のコマンドを使用して行1に移動できます。

g or < or ESC-<
      Go to line N in the file, default 1 (beginning of file).

コンテンツ全体を次にパイプしますcat

| <m> shell-command
      <m> represents any mark letter. Pipes a section of the input file to the
      given shell command. The section of the file to be piped is between the
      first line on the current screen and the position marked by the letter. 
      <m> may also be ^ or $ to indicate beginning or end of file respectively.

したがって、次のいずれかを実行します。

g|$cat > filename

または:

<|$cat > filename

つまり、gまたは<Gまたは未満) | $(管路それからドルcat > filenameEnter
これは、入力がパイプであるか通常のファイルであるかに関係なく機能します。

おすすめ記事