在bash中粘贴带有扩展分隔符的文件 [英] Paste files with extended delimiter in bash

查看:52
本文介绍了在bash中粘贴带有扩展分隔符的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

今天,我想知道如何用这个分隔符粘贴几个文件:,,.

Today, I was wondering how to paste several files with this delimiter: ,,.

当我使用 like 时:

When I use like:

paste -d',,' ...

输出只引入一个,

我需要双逗号才能更好地处理 csv 文件,提前感谢您提供任何线索

I need double comma for better handling csv files, Thanks in advance for any clue

推荐答案

如果您能识别出文件中未使用的字符,您可以分两步完成.

If you can identify a character which is not used in the file, you can do this in two steps.

paste -d '~' file1 file2 | sed 's/~/,,/'

显然,如果波浪号已存在于您的数据中,请使用不同的分隔符.控制角色可能是一个相当安全的赌注,代价是操纵起来有点麻烦.(在 Bash 中,您可以使用例如 $'\001' 来生成 ctrl-A 等)

Obviously, if the tilde already exists in your data, use a different delimiter. A control character could be a fairly safe bet, at the expense of being slightly pesky to manipulate. (In Bash, you can use e.g. $'\001' to produce a ctrl-A, etc.)

这篇关于在bash中粘贴带有扩展分隔符的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆