Awk 基于新行将列转换为行
我有这样的文件Awk 基于新行将列转换为行,awk,xargs,perl,Awk,Xargs,Perl,我有这样的文件 d e e s k a b c d dee sk abcd dee sk abcd 我只需要像这样转换 d e e s k a b c d dee sk abcd dee sk abcd 为此,我使用了awk和xargs xargs < file|awk '{ gsub (" ", "", $0); print}' xargs
d
e
e
s
k
a
b
c
d
dee
sk
abcd
dee
sk
abcd
我只需要像这样转换
d
e
e
s
k
a
b
c
d
dee
sk
abcd
dee
sk
abcd
为此,我使用了awk和xargs
xargs < file|awk '{ gsub (" ", "", $0); print}'
xargs
但是它没有产生预期的结果请尝试以下内容
$ awk -v RS= -v OFS='' '{$1=$1}1' file
dee
sk
abcd
awk '
!NF && value{
print value
value=""
next
}
NF{
value=value $0
}
END{
if(value){
print value
}
}' Input_file
使用:
输出
-00
类似于awk-vrs=