2021年11月18日 星期四

Linux 用 less 指令儲存檔案

查看內容時,使用「|」指令:
| <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 posi‐
              tion  marked  by the letter.  <m> may also be ^ or $ to indicate beginning or end of file respec‐
              tively.  If <m> is . or newline, the current screen is piped.
  1. 按「|」,進入 shell-command
  2. 按「^」,表示從頭到目前位置看到的內容;
    按「$」,表示從頭到尾的內容。
  3. 輸入「cat > 要另存的檔案名稱」,按 enter 後即會儲存。


查看內容時,使用「s」指令:
s filename
      Save the input to a file.  This only works if the input is a pipe, not an ordinary file.
這只在查看的內容為 pipe 時,才可用,
例如:
$ cat test.txt | less
打開檔案後,按「s」,再輸入「要另存的檔案名稱」,按 enter 後即會儲存。




參考:

沒有留言:

張貼留言