跳转到主要内容

x2y: 在DOS、Mac(预OS X)和Unix之间转换行结束符

项目描述

在DOS、Mac(预OS X)和Unix之间转换行结束符

在哪里

  • DOS = ‘\r\n’

  • Mac = ‘\r’ (OS9)

  • Unix = ‘\n’

注意:这里的Mac是OS9及之前。OS X的行结束符是Unix。

示例

将Unix行结束符转换为DOS行结束符

$ x2y -f unx -t dos file.txt

上述命令将Unix行结束符转换为DOS行结束符。结果将写回源文件。

如果您想写入另一个文件,请使用-o或-d选项(见下文)。

$ x2y -o output.txt -f unx -t dos file.txt

将转换后的文件写入output.txt

$ x2y -d outputs -f unx -t dos file.txt

将转换后的文件保存到outputs目录。

要备份源文件,请使用-b选项。例如

$ x2y -b bak -f unx -t dos file.txt

在写入转换后的文件之前将源文件重命名为“bak”扩展名。

安装

pip install x2y

用法

usage: x2y [options] --from line-ending --to line-ending File [File ...]

x2y: convert line ending between DOS, Mac (pre OS X) and Unix

positional arguments:
  File                  Files to convert

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --debug               Turn on debug logging.
  --debug-log FILE      Save debug logging to FILE.
  -b BACKUP EXTENTSION, --backup BACKUP EXTENTSION
                        Save a backup of the input file by renaming with
                        BACKUP EXTENTSION. Ignored if the -o option is given.
                        Default: None.
  -d DIRECTORY, --directory DIRECTORY
                        Save extracted text to DIRECTORY. Ignored if the -o
                        option is given.
  -f {dos,mac,unx}, --from {dos,mac,unx}
                        Line ending to convert from.
  -o FILE, --output FILE
                        Save extracted text to FILE. If not given, the output
                        file is named the same as the input file but with a
                        txt extension. The extension can be changed with the
                        -e option. Files are opened in append mode unless the
                        -X option is given.
  -t {dos,mac,unx}, --to {dos,mac,unx}
                        Line ending to convert to.
  -A, --suppress-file-access-errors
                        Do not print file/directory access errors.

项目详情


下载文件

下载适用于您平台文件的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分发

x2y-0.1.0.tar.gz (9.3 kB 查看散列)

上传时间:

构建分发

x2y-0.1.0-py2.py3-none-any.whl (8.3 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持