当分隔符为 ||| 时,AWK 无法拆分行
AWK is not able to split a line when seperator is |||
假设我有一个文件如下 (file.txt
):
My name is John ||| Second part of example.
获取第一部分(直到 |||
)
我做了以下事情:
awk -F '|||' '{print }' file.txt
但是,这个命令给了我整行。
如何获取每行的部分直到 |||
?
这应该有效:
awk -F"[|][|][|]" '{print }' file
My name is John
第二部分
awk -F"[|][|][|]" '{print }' file
Second part of example.
正如@glenn 所示:
awk -F"[|]{3}" '{print }' file
My name is John
假设我有一个文件如下 (file.txt
):
My name is John ||| Second part of example.
获取第一部分(直到 |||
)
我做了以下事情:
awk -F '|||' '{print }' file.txt
但是,这个命令给了我整行。
如何获取每行的部分直到 |||
?
这应该有效:
awk -F"[|][|][|]" '{print }' file
My name is John
第二部分
awk -F"[|][|][|]" '{print }' file
Second part of example.
正如@glenn 所示:
awk -F"[|]{3}" '{print }' file
My name is John