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 查看哈希值)
关闭
x2y-0.1.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1dff349d608d18fa7532a92b13a831cf159fa00cfc891f74ece6cb94cab5fcbd |
|
MD5 | 25f72db966e2692d60c08cfd6070d412 |
|
BLAKE2b-256 | da11503478d692063a6dfe38458584f4e524d2fef3e1275a05ad328ffe1015c7 |
关闭
x2y-0.1.0-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 65966d93d4b79f1e10fc085760ae7fe19a9772ab5ad7862f7c11c7779ef8561a |
|
MD5 | 54e5482b8738d2d124efc02f36ae45c6 |
|
BLAKE2b-256 | d96819a4ee9688f6e9f431b9a3d1d9ed45750eb5c6e46a6745cddcecd968f2e2 |