找回密码
 注册
关于网站域名变更的通知
查看: 410|回复: 3
打印 上一主题 下一主题

Linux fold命令

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2021-9-23 09:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x

, w9 O  D( G7 N- q4 mLinux fold命令用于限制文件列宽。
; }" Y- O# ]: ]  l9 V/ n6 b9 B% H# x+ o, u& O# c4 z
fold指令会从指定的文件里读取内容,将超过限定列宽的列加入增列字符后,输出到标准输出设备。若不指定任何文件名称,或是所给予的文件名为"-",则fold指令会从标准输入设备读取数据。
4 y, G3 U; p( t# f" M1 {1 \- e0 l+ I: D% \" M: k

; |: h  V% \4 ^/ m) b5 K; K语法
7 S) L0 x$ `4 ~; Z5 _# Y" c4 _; \7 D8 k4 }5 ~3 x* `$ [, `1 f% K
fold [-bs][-w<每列行数>][--help][--version][文件...]( A8 g7 N" e7 G. d' u( [
# q/ [* [7 k" |' x% V" T2 }8 T8 _
3 b, q3 k4 P0 A% w2 P

' W' A% f) Q- g9 J参数:9 H& {+ {- v2 j- V0 b
( k/ h  v$ `2 I* g+ Z% k/ k+ l
-b或--bytes 以Byte为单位计算列宽,而非采用行数编号为单位。
& l. s( T! r" c, P0 V2 x7 X-s或--spaces 以空格字符作为换列点。( I9 A+ k0 e8 s. M+ `
-w<每列行数>或--width<每列行数> 设置每列的最大行数。
5 _& |1 T* f! ~# y9 C1 m8 H9 e--help 在线帮助。: e6 v' ^& m. L8 \1 d3 E
--version 显示版本信息。
3 _7 h% ^, D, f4 ^: h7 U; q8 v4 D0 \8 l

4 s, F! d7 l8 S5 e6 Q5 N  X8 d9 U3 C3 o
实例
, `2 [% `9 _: {7 y( y- q2 j( n* S# v
将一个名为testfile 的文件的行折叠成宽度为30,可使用如下命令:
; S2 Z# {! Z* `' G
' G4 i' o5 b, Lfold -w 30 testfile+ L4 R6 k7 n: Z7 t

% q2 J+ E  N7 ]/ U: F/ j  Z
% }- i) ~# Y2 i7 N为了对比,先将testfile文件输出如下:' B, G' A! d$ F9 J- U+ W& J8 j7 ]  M- O

7 i9 f9 t  g7 j$ cat testfile #查看testfile 中的内容  
1 M6 a4 C$ A; S* j- L4 xLinux networks are becoming more and more common, but
0 o  Y0 v, ?' qsecurity is often an overlooked  ( |2 m' p% I9 r
issue. Unfortunately, in today’s environment all networks % u) Z' ^% K* p& q' M/ J2 e
are potential hacker targets,  0 E$ d9 d3 G, h8 a( z
from top-secret military research networks to small home LANs.  / u- a3 V" W( U8 H0 S9 A" B( g
Linux Network Security focuses on securing Linux in a
: P; }$ ?1 b' ]+ C9 V1 l3 X3 o/ \networked environment, where the  ( y: D4 o" T* Y& w1 S
security of the entire network needs to be considered : f0 Z- u+ Q: Q) Z" U
rather than just isolated machines.  8 ^  \2 q) o. [. g% J
It uses a mix of theory and practical techniques to
. l8 t2 s8 I1 N* V! xteach administrators how to install and  5 B5 i# \3 H( c5 v" n
use security applications, as well as how the
4 @  W& m  D* H4 Vapplications work and why they are necessary.
2 a) {9 Z) v% b& C, o: h0 E# z9 ]$ g: a0 R5 F( t4 E+ s9 r" `, G7 I
& s+ i% w+ ]/ Y7 n8 S3 V/ Y' M
然后使用fold命令折叠显示:$ G' F# O1 N- M& h8 J9 A5 V0 D
$ Y, x6 f0 l) F- N& h
$ fold -w 30 testfile #行折叠成宽度为30,显示testfile 文件  # s- {  L8 b* j7 o
Linux networks are becoming mo  
, `4 Q5 G1 y: k' ~: s7 U1 G& hre and more common, but securi  
' c$ Q# U0 i6 Aty is often an overlooked issu  + N+ @* `. p/ {5 {
e. Unfortunately, in today’s  , Z2 {. `' Q! |
environment all networks are  % X' S4 A1 g! C- |0 O1 l( |+ S
potential hacker targets, from  
" l! k) _1 I& i' U: d4 M- m$ Mtop-secret military research  & j! S& c% n2 V
networks to small home LANs.  
8 M9 t& }% a- }! C1 bLinux Network Security focuses  
. b' ^( p6 E+ A0 w- x/ u$ Ton securing Linux in a networ  
* M7 ^5 |' x7 M4 d, aked environment, where the sec  - l4 X9 V6 C, E* `. f. m: a
urity of the entire network ne  - U! }5 j- K$ A1 L& k4 I4 {
eds to be considered rather th  
. e- r! p# u  Y4 g. g/ uan just isolated machines. It  
0 ~& W- r; G* h1 k- Z2 kuses a mix of theory and pract  5 J7 n0 E% C" o, E/ m
ical techniques to teach admin  " d, L- ~* U. H2 Q4 n) H. [. a2 d
istrators how to install and u  
2 M# a- u1 H0 U7 nse security applications, as w  
1 N5 q' N, o+ O% a# Z; f, @: |( nell as how the applications wo  1 f  {0 m# F) l  t' R* O
rk and why they are necessary
& R+ u1 T! |) {; k

该用户从未签到

2#
发表于 2021-9-23 13:25 | 只看该作者
Linux fold命令
  • TA的每日心情

    2019-11-29 15:37
  • 签到天数: 1 天

    [LV.1]初来乍到

    3#
    发表于 2021-9-23 13:25 | 只看该作者
    Linux fold命令用于限制文件列宽

    该用户从未签到

    4#
    发表于 2021-9-23 13:26 | 只看该作者
    fold指令会从指定的文件里读取内容,将超过限定列宽的列加入增列字符后,输出到标准输出设备
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-11-24 07:16 , Processed in 0.140625 second(s), 23 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表