awk不使用管道或文本文件打印OFS

awk不使用管道或文本文件打印OFS,awk,Awk,我在ubuntu上,请帮忙我做错了什么 $ echo "hello there" | awk -v OFS=";" '{print $0 $1 $2}' hello therehellothere $ echo "hello there" | awk 'BEGIN {OFS=","} {print $0 $1 $2}' hello therehellothere $ awk 'BEGIN {OFS=","} {print $0 $1 $2}' hello.txt hello therehello

我在ubuntu上,请帮忙我做错了什么

$ echo "hello there" | awk -v OFS=";" '{print $0 $1 $2}'
hello therehellothere
$ echo "hello there" | awk 'BEGIN {OFS=","} {print $0 $1 $2}'
hello therehellothere
$ awk 'BEGIN {OFS=","} {print $0 $1 $2}' hello.txt
hello therehellothere

打印需要
来分隔每个输出变量/值:

$ echo "hello there" | awk -v OFS=";" '{print $0,$1,$2}'
#=> hello there;hello;there
$ echo "hello there" | awk 'BEGIN {OFS=","} {print $0,$1,$2}'
#=> hello there,hello,there
空格
只是将每个字符串/变量连接起来。
在需要OFS时使用空间是错误的,但对于某些需要,它很方便