前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >fold命令

fold命令

作者头像
WindrunnerMax
发布2020-12-16 15:26:12
4110
发布2020-12-16 15:26:12
举报
文章被收录于专栏:Czy‘s Blog

fold命令

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

语法

代码语言:javascript
复制
fold [OPTION]... [FILE]...

参数

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

示例

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

代码语言:javascript
复制
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个字符。

代码语言:javascript
复制
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选项用于分隔空格上的行,以便不打断单词。

代码语言:javascript
复制
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.

每日一题

代码语言:javascript
复制
https://github.com/WindrunnerMax/EveryDay

参考

代码语言:javascript
复制
https://leetcode-cn.com/problems/dota2-senate/
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-12-12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • fold命令
    • 语法
      • 参数
        • 示例
          • 每日一题
            • 参考
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档