Latest web development tutorials

Linux fold命令

Linux 命令大全 Linux命令大全

Linux fold命令用於限製文件列寬。

fold指令會從指定的文件裡讀取內容,將超過限定列寬的列加入增列字符後,輸出到標準輸出設備。 若不指定任何文件名稱,或是所給予的文件名為"-",則fold指令會從標準輸入設備讀取數據。

語法

fold [-bs][-w<每列行数>][--help][--version][文件...]

參數 :

  • -b或--bytes 以Byte為單位計算列寬,而非採用行數編號為單位。
  • -s或--spaces 以空格字符作為換列點。
  • -w<每列行數>或--width<每列行數> 設置每列的最大行數。
  • --help 在線幫助。
  • --version 顯示版本信息。

實例

將一個名為testfile 的文件的行折疊成寬度為30,可使用如下命令:

fold -w 30 testfile

為了對比,先將testfile文件輸出如下:

$ cat testfile #查看testfile 中的内容  
Linux networks are becoming more and more common, but 
security is often an overlooked  
issue. Unfortunately, in today’s environment all networks 
are potential hacker targets,  
from top-secret military research networks to small home LANs.  
Linux Network Security focuses on securing Linux in a 
networked environment, where the  
security of the entire network needs to be considered 
rather than just isolated machines.  
It uses a mix of theory and practical techniques to 
teach administrators how to install and  
use security applications, as well as how the 
applications work and why they are necessary. 

然後使用fold命令折疊顯示:

$ fold -w 30 testfile #行折叠成宽度为30,显示testfile 文件  
Linux networks are becoming mo  
re and more common, but securi  
ty is often an overlooked issu  
e. Unfortunately, in today’s  
environment all networks are  
potential hacker targets, from  
top-secret military research  
networks to small home LANs.  
Linux Network Security focuses  
on securing Linux in a networ  
ked environment, where the sec  
urity of the entire network ne  
eds to be considered rather th  
an just isolated machines. It  
uses a mix of theory and pract  
ical techniques to teach admin  
istrators how to install and u  
se security applications, as w  
ell as how the applications wo  
rk and why they are necessary 

Linux 命令大全 Linux命令大全