Commande Linux fold
Encyclopédie des commandes Linux
La commande Linux fold est utilisée pour limiter la largeur des colonnes d'un fichier.
La commande fold lit le contenu du fichier spécifié, ajoute des caractères de retour à la ligne aux colonnes dépassant la largeur de colonne limitée, puis envoie le résultat vers le périphérique de sortie standard. Si aucun nom de fichier n'est donné, ou si le nom de fichier donné est "-", la commande fold lit les données depuis l'entrée standard.
Syntaxe
fold [-bs][-w<每列行数>][--help][--version][文件...]
Parameters:
- -b ou --bytes Calcule la largeur de colonne en octets, plutôt que d'utiliser le nombre de lignes comme unité.
- -s ou --spaces Utilise des caractères d'espace comme points de coupure de colonne.
- -w<nombre de caractères par ligne> ou --width<nombre de caractères par ligne> Définit la largeur maximale de ligne.
- --help Aide en ligne.
- --version Affiche les informations de version.
Exemples
Pour plier les lignes d'un fichier nommé testfile à une largeur de 30, vous pouvez utiliser la commande suivante :
fold -w 30 testfile
À titre de comparaison, affichez d'abord le fichier testfile comme suit :
$ 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.
Utilisez ensuite la commande fold pour le plier et l'afficher :
$ 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 necessaryAutres extensions