使用 SOH 分隔符在 bash 中拆分一行文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2602538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 21:55:37  来源:igfitidea点击:

Split a line of text in bash using SOH delimiter

bash

提问by syker

How do I split a line of text in bash using SOH delimiter?

如何使用 SOH 分隔符在 bash 中拆分一行文本?

回答by ghostdog74

you can use the octal value of SOH as a delimiter using awk.

您可以使用 awk 将 SOH 的八进制值用作分隔符。

$ awk -F"
IFS=`echo -e ''`
1" '{print }' file

回答by Andy Mortimer

You can set the IFS variable to change the delimiter between words. (Don't forget to save the old value so you can restore it when you're done.)

您可以设置 IFS 变量来更改单词之间的分隔符。(不要忘记保存旧值,以便在完成后恢复它。)

Based on a quick google I assume "SOH delimiter" is the character with code 1, so you need to get that odd character into IFS:

基于一个快速的谷歌,我假设“SOH 分隔符”是代码为 1 的字符,因此您需要将该奇数字符放入 IFS:

##代码##

If that's not enough, you probably need to expand on "split a line of text". What do you want to split it into?

如果这还不够,您可能需要扩展“拆分一行文本”。你想把它分成什么?