fold命令

fold命令

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

语法#

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

参数#

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

示例#

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

Copy
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个字符。

Copy
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选项用于分隔空格上的行,以便不打断单词。

Copy
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.

每日一题#

Copy
https://github.com/WindrunnerMax/EveryDay

参考#

Copy
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/
posted @   WindRunnerMax  阅读(136)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示
CONTENTS