| <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.
- 按「|」,進入 shell-command
- 按「^」,表示從頭到目前位置看到的內容;
按「$」,表示從頭到尾的內容。 - 輸入「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 後即會儲存。
參考:
- https://unix.stackexchange.com/questions/172624/how-do-i-write-all-lines-from-less-to-a-file
How do I write all lines from less to a file? - Unix & Linux Stack Exchange - https://newbedev.com/how-can-i-save-the-current-contents-of-less-to-a-file
How can I save the current contents of less to a file?
沒有留言:
張貼留言