fold命令

fold命令用于限制文件列宽,其会从指定的文件里读取内容,将超过限定列宽的列加入增列字符后,输出到标准输出设备。若不指定任何文件名称,或是所给予的文件名为-,则fold命令会从标准输入设备读取数据。

语法

fold [OPTION]... [FILE]...

参数

  • -b, --bytes: 计算字节数而不是列数。
  • -s, --spaces: 在空格处跳过。
  • -w, --width=WIDTH: 使用n列,而不是默认值80
  • --help: 显示帮助信息。
  • --version: 显示版本信息。

示例

使用fold命令进行分隔,每行最多包含默认值80个字符。

fold file.txt
# fold command in Linux wraps each line in an input file to fit a specified width
# and prints it to the standard output. By default, it wraps lines at a maximum wi
# dth of 80 columns but this is configurable. To fold input using the fold command
# pass a file or standard input to the command.

使用fold命令进行分隔,指定每行最多包含默认值50个字符。

fold -w 50 file.txt
# fold command in Linux wraps each line in an input
# file to fit a specified width and prints it to the
# standard output. By default, it wraps lines at a
# maximum width of 80 columns but this is configurab
# le. To fold input using the fold command pass a fi
# le or standard input to the command.

使用fold命令进行分隔,并使用-s选项用于分隔空格上的行,以便不打断单词。

fold -w 50 -s file.txt
# fold command in Linux wraps each line in an input
# file to fit a specified width and prints it to
# the standard output. By default, it wraps lines
# at a maximum width of 80 columns but this is
# configurable. To fold input using the fold
# command pass a file or standard input to the
# command.

每日一题

https://github.com/WindrunnerMax/EveryDay

参考

https://www.computerhope.com/unix/ufold.htm
https://www.runoob.com/linux/linux-comm-fold.html
https://www.geeksforgeeks.org/fold-command-in-linux-with-examples/

fold命令的更多相关文章

  1. 如何使用 sort 命令来找到几个版本库之间的共同文件

    Linux 命令行中的词汇出现次数统计 导航: 需求: 需要快速了解 ChromeExtended 编写. 操作: 从 Github 上找到了五个前辈们写的 Mode ,需要对其进行分析. 需要用到的 ...

  2. Linux文本过滤常用命令(转)

    01 cat命令 通常用来显示文本文件的内容 一般用来查看比较短的文本文件,因为其缓冲区有限 -s选项可以用来合并文件中多余的空行,多个空行将被压缩为一个空行; -n选项可以显示行号 -b选项可以跳过 ...

  3. Linux命令-文本编辑(一)

    Linux命令-文本编辑(一) Linux col命令 Linux col命令用于过滤控制字符. 在许多UNIX说明文件里,都有RLF控制字符.当我们运用shell特殊字符">&quo ...

  4. Vim篇

    Vim编辑器中的一些常用命令: 1:shift+* , 选取光标所在处的整个字符,并查找.(十分方便),快捷键gd 2:set nu , 显示各行行号,使得基于行的命令更方便. 3:shift+% , ...

  5. UNIX 系统上的文本操作简介

    http://www.oschina.net/question/129540_53561 UNIX 的基本哲学之一就是创建只做一件事并将这一件事做好的程序(或进程).这一哲学要求认真考虑接口以及结合这 ...

  6. 《Linux.Shell编程从入门到精通》读书笔记

    第一章 第一个Shell程序 以 #!解析器名称 开头,表示选择哪个解释器解释shell脚本 source命令 export命令 env命令 unset命令 第二章 shell编程基础 函数传递 标准 ...

  7. [Linux] 如何在 Linux 中提取随机数

    如何在 Linux 中提取随机数 一.设备文件 /dev/random & /dev/urandom 字符特殊文件 /dev/random 和 /dev/urandom (存在于Linux 1 ...

  8. Linux基础命令---fold

    fold 按照指定的宽度显示文件. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法       fold [选项]  fil ...

  9. Linux常用命令大全

    系统信息 arch 显示机器的处理器架构(1)  uname -m 显示机器的处理器架构(2)  uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIO ...

  10. 【原】Learning Spark (Python版) 学习笔记(一)----RDD 基本概念与命令

    <Learning Spark>这本书算是Spark入门的必读书了,中文版是<Spark快速大数据分析>,不过豆瓣书评很有意思的是,英文原版评分7.4,评论都说入门而已深入不足 ...

随机推荐

  1. [转帖]linux audit审计(7-1)--读懂audit日志

    https://www.cnblogs.com/xingmuxin/p/8807774.html  auid=0 auid记录Audit user ID,that is the loginuid.当我 ...

  2. [转帖]linux服务之tuned

    https://www.cnblogs.com/createyuan/p/5701650.html RHEL/CentOS 在 6.3 版本以后引入了一套新的系统调优工具 tuned/tuned-ad ...

  3. Oracle的awr的学习与整理

    Oracle的awr的学习与整理 背景 本来想上周末进行一下总结和汇总 因为周末两天进行了一次长时间的培训.所以没有成行. 只能在工作之余找时间进行总结. 数据库部分自己一个不是很强. 其实也比较抗拒 ...

  4. [转帖]适用于 Azure VM 的 TCP/IP 性能优化

    https://learn.microsoft.com/zh-cn/azure/virtual-network/virtual-network-tcpip-performance-tuning?con ...

  5. Oracle12c 快速启动命令设置

    Oracle12c 安装完成之后 一般不会自动启动需要进行一下简单的设置才可以. 方法也比较简单. 可以使用 oracle 自带的 dbstart的命令执行服务启动 需要注意的事项是: 第一修改一个参 ...

  6. 一个思路:实现 golang 中的 `__file__` `__line__` 宏

    作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢! cnblogs博客 zhihu Github 公众号:一本正经的瞎扯 测试 zaplog 发现,开启 caller 的调用,会使 ...

  7. ngnix在linux安装并设置反向代理

    一.nginx安装 1.安装Nginx依赖的环境 安装Nginx依赖的gcc的编译环境: yum install gcc-c++ Nginx的http模块需要使用pcre来解析正则表达式,需要安装pc ...

  8. Unity2019及Unity2020打包android的环境配置

    2019安卓打包只有gradle模式了,因为谷歌把adt删了 unity2019可以自定义gradle模板,国内请把repo地址改成阿里云的源 unity2019打apk配置 引擎版本:unity20 ...

  9. TienChin-课程管理-课程搜索

    后端 新建 CourseVO.java: /** * CourseVO类是一个课程的值对象,用于存储课程的相关信息. * 它包含了课程的名称.类型.适用对象.最低价格和最高价格等属性. */ publ ...

  10. 【3】超级详细matplotlib使用教程,手把手教你画图!(多个图、刻度、标签、图例等)

    相关文章: 全网最详细超长python学习笔记.14章节知识点很全面十分详细,快速入门,只用看这一篇你就学会了! [1]windows系统如何安装后缀是whl的python库 [2]超级详细Pytho ...