fold命令
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/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理