我有一个包含大量 vcard 的 vcf 文件。
将 vcf 文件导入到 Outlook 时,它似乎只导入了第一个 vcard。
因此我想把它们分开。
鉴于 vcard 以
BEGIN:VCARD
Run Code Online (Sandbox Code Playgroud)
并以
END:VCARD
Run Code Online (Sandbox Code Playgroud)
将每个 vcard 拆分为自己的文件的最佳方法是什么。
谢谢
更新
感谢所有的回应。对于这种性质的问题,有多种方法可以给猫剥皮。这是我选择我所做的那个的原因。
围捕
这是我从每个答案中喜欢的内容以及促使我选择其中一个答案的汇总。
csplit: 我真的很喜欢这种方法的简洁性。我只是希望它也能够设置文件扩展名。gawk: 它做到了我要求的一切。paralell: 工作了。但我不得不安装新东西。(它还决定在我的主目录中创建一个新的 /bin 目录)perl:我喜欢它根据联系人的姓名创建 vcf。但是 -o 选项并没有真正起作用结论
perl因为有点破paralell因为我必须安装新东西csplit,因为据我所知,它无法在输出文件上创建扩展名cmp太:)我想在 bash 脚本中运行这样的命令:
freebcp <authentication and other parameters> -t "," -r "\r\n"
Run Code Online (Sandbox Code Playgroud)
直接在命令行上运行时,该命令按预期工作。但是当放在 bash 脚本中的变量中时,它会返回如下错误:
Msg 20104, Level 3
Unexpected EOF encountered in bcp datafile
Msg 20074, Level 11
Attempt to bulk copy an oversized row to the server
bcp copy in failed
Run Code Online (Sandbox Code Playgroud)
当命令放在变量中并且双引号被转义时:
cmd="freebcp ${db_name}.dbo.${table_name} in ${p_file} -S ${server_name} -U ${username} -P ${password} -t \",\" -r \"\r\n\" -c"
`$cmd`
Run Code Online (Sandbox Code Playgroud)
注意:将以下内容按预期工作:
`freebcp ${db_name}.dbo.${table_name} in ${p_file} -S ${server_name} -U ${username} -P ${password} -t "," -r "\r\n" -c`
Run Code Online (Sandbox Code Playgroud)
所以我知道有一些引用/转义/扩展问题,但我不知道如何解决它。
注 2 …