Latest web development tutorials

Linux fold command

Linux command Daquan Linux command Daquan

Linux fold command is used to limit the file column width.

fold instruction reads the content from the specified file will be more than the width of the column after column added additional characters to the standard output device. If not specify any file name or file name given by "-", then fold instruction reads data from the standard input device.

grammar

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

Parameters:

  • -b or --bytes in Byte column width for the unit, rather than the use of the line number of units.
  • -s or a space character as --spaces Breaks points.
  • -w <number of lines per column> or --width <number of lines per column> Sets the maximum number of lines per column.
  • --help online help.
  • --version display version information.

Examples

The row named testfile file folded into a width of 30, use the following command:

fold -w 30 testfile

For comparison, the first testfile file output is as follows:

$ 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. 

Then use the fold folding display command:

$ 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 command Daquan Linux command Daquan