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

Linux fold命令

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

+ O2 h7 U3 [$ }" r1 u/ c5 dLinux fold命令用于限制文件列宽。
9 {, W3 I+ a+ ^& b% d; f7 e+ s2 G9 h; o6 t( v
fold指令会从指定的文件里读取内容,将超过限定列宽的列加入增列字符后,输出到标准输出设备。若不指定任何文件名称,或是所给予的文件名为"-",则fold指令会从标准输入设备读取数据。
; A; p4 I. R6 F/ v9 X& O
/ s4 s( o" T5 @4 X, C9 G1 O! R
9 V9 p5 a0 F  p0 {3 d2 P5 ]2 D语法" o7 A) W3 q# J: S$ M2 l. b  Y1 g8 Y# D
6 O* e/ H" C& [) q; ~7 [$ v
fold [-bs][-w<每列行数>][--help][--version][文件...]  @: L1 ~. ?$ |% v$ U6 f
0 {. L; W% D' e
% f) V! W* ^% Y% E/ u" P6 p
! B1 k" k' c  D  P; M+ g
参数:' c0 n2 p5 Q. u" H6 G" f/ f
6 e3 G, C9 c3 T
-b或--bytes 以Byte为单位计算列宽,而非采用行数编号为单位。& R4 w8 c+ C# S, T. _7 S+ i% a& d
-s或--spaces 以空格字符作为换列点。' S; \2 x' @) C- L! e3 S
-w<每列行数>或--width<每列行数> 设置每列的最大行数。+ I0 P6 ?* ~& t& v, c
--help 在线帮助。. P$ R1 h; K% U% _. K
--version 显示版本信息。
+ D& m3 j: l6 N8 z
2 |/ Z. G6 k5 l% L8 K, m. [% D  @% B& S% r0 z: J
4 ~( `$ P/ d" ^2 ?4 n' ?8 r
实例
1 P3 v; o  M' \& p2 R! F1 O+ P% D) r8 x6 q5 C4 _
将一个名为testfile 的文件的行折叠成宽度为30,可使用如下命令:" C; f, P6 a( ^0 r1 _& @
# Q4 r! T0 A& Z" ^
fold -w 30 testfile9 r8 k1 y- g# p& m- ?( J; ]- n
: p' t- Z4 B7 P0 R. h8 L

  e0 c7 B+ m, ]  R1 l$ L为了对比,先将testfile文件输出如下:+ W1 v. Z/ B2 ^( Y5 G  z4 O& J

# {( T8 X( c8 i8 e$ cat testfile #查看testfile 中的内容  ! c) ]5 g+ _0 V  R: {+ J" A
Linux networks are becoming more and more common, but
, }5 T% Y) F- Q1 L; E% u% v+ nsecurity is often an overlooked  9 k; _/ f, s9 N- D- G/ y4 ?
issue. Unfortunately, in today’s environment all networks
7 }4 E3 w' G9 L, N' e. p: y, Iare potential hacker targets,  
0 k  t4 J' A, v4 {from top-secret military research networks to small home LANs.  
3 ~* q3 ^7 g5 }  N" ?" ~4 ]Linux Network Security focuses on securing Linux in a
- y1 f; y* ~* Q6 j+ mnetworked environment, where the  : v) ?8 z5 Z0 m/ C+ Z
security of the entire network needs to be considered 5 K  c5 h; f% Y1 q, L% d8 q
rather than just isolated machines.  
; l' f/ R) s8 ~/ K' RIt uses a mix of theory and practical techniques to 9 D; z- o  ~: P4 z. D' F" \- q
teach administrators how to install and  
1 k2 e7 a, ]5 v' A1 nuse security applications, as well as how the * e; ]. R3 S# T6 r$ S
applications work and why they are necessary.
) v" J* y$ w9 l* n, {# N5 j3 o& P# R0 ]
+ f9 ?" u) m- N# n; L5 x, X, _5 @, Q9 m- n
然后使用fold命令折叠显示:1 B9 d& K8 K5 e; i
  A. o3 {$ b3 H3 P/ Y5 Z/ p. J" h
$ fold -w 30 testfile #行折叠成宽度为30,显示testfile 文件  
; k: ^1 F1 [* z9 J9 OLinux networks are becoming mo  
4 T& Q& c8 s0 Lre and more common, but securi  
: s' m$ v# [) N! @( Pty is often an overlooked issu  
$ j  f2 S1 f$ D7 Ae. Unfortunately, in today’s  : T" S1 v# S1 b& U* Q
environment all networks are  
3 l/ F$ R9 D- I  r% ^" d' J  t- qpotential hacker targets, from  
, s. {& V; B+ R3 W/ d0 Ytop-secret military research  9 ~+ n; Z( c& Z0 r& w9 G
networks to small home LANs.  : q: ?$ ?/ B& q$ S6 E( u$ O7 q
Linux Network Security focuses  
- H8 L* b; O& r! I) K+ _on securing Linux in a networ  
0 W- a5 E" C0 C' Xked environment, where the sec  
" n4 Z7 n7 |( t' E& A" aurity of the entire network ne  
. i, d0 G. L8 f4 j& i3 J$ {- Zeds to be considered rather th  
5 p' |* w$ S. ~$ R( I  H0 K7 c+ ]an just isolated machines. It  , y: Y6 V* W2 a# }
uses a mix of theory and pract  + B/ V5 D) P3 t& s
ical techniques to teach admin  
" y3 g6 V9 X/ [5 Histrators how to install and u  0 P0 r( W$ D) k' u0 B
se security applications, as w  ; L  A/ Q. x4 c
ell as how the applications wo  ' R0 j- Z) {6 c/ p4 U( P
rk and why they are necessary 9 a. d& M* r5 C+ |0 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 04:34 , Processed in 0.140625 second(s), 23 queries , Gzip On.

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

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

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