Команда Linux fold

Linux 命令大全Энциклопедия команд Linux

Команда fold в Linux используется для ограничения ширины столбцов файла.

Команда fold считывает содержимое из указанного файла, добавляет символы переноса в столбцы, превышающие заданную ширину столбца, и выводит на устройство стандартного вывода. Если имя файла не указано или указано имя файла "-", команда fold считывает данные из стандартного ввода.

Синтаксис

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

Parameters:

  • -b или --bytes Вычисляет ширину столбца в байтах, а не использует количество строк в качестве единицы измерения.
  • -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

Другие расширения