anyone could help me to achieve this ,normally AWK read file
a b c
as
$1:a
$2:b
$3:c
how to read this file
a
b
c
as
$1:a
$2:b
$3:c
Many thanks for help .
anyone could help me to achieve this ,normally AWK read file
a b c
as
$1:a
$2:b
$3:c
how to read this file
a
b
c
as
$1:a
$2:b
$3:c
Many thanks for help .
You can unset the Record Separator and change the Input Field Separator to the newline character:
$ awk -F'\n' -vRS='' '{print $1,$2,$3}' file
a b c
Using GNU awk for multi-char RS:
$ cat file
a
b
c
d
$ awk -v RS='^$' '{for (i=1;i<=NF;i++) print "$"i"="$i; print "----"}' file
$1=a
$2=b
$3=c
$4=d
----
Note the difference wrt d
with Tom's solution of setting RS to the NULL string:
$ awk -F'\n' -v RS='' '{for (i=1;i<=NF;i++) print "$"i"="$i; print "----"}' file
$1=a
$2=b
$3=c
----
$1=d
----
Think about how you want your script to behave if there are blank lines in the file.