so, basically, at the begining, put li value to null,
and if first or 3rd line, then... hmm I still dont' understand this part of
how {li=$0"|"li} equals concatenate that row(which is what's in 1st and 3rd line) with value in variable(which is null at this point? but I am assuming this becomes.. first line.. and then.. 3rd line ..
so value becomes 3rdline|1stline <-- separated by | ?
I thought $0 was the entire record.. how does assigning entire record to li becomes this meaning? can you elaborate little further please?
Originally Posted by convenientstore
Trying to understand below;
so, basically, at the begining, put li value to null,
and if first or 3rd line, then... hmm I still dont' understand this part of
how {li=$0"|"li} equals concatenate that row(which is what's in 1st and 3rd line) with value in variable(which is null at this point? but I am assuming this becomes.. first line.. and then.. 3rd line ..
so value becomes 3rdline|1stline <-- separated by | ?
I thought $0 was the entire record.. how does assigning entire record to li becomes this meaning? can you elaborate little further please?
Originally Posted by convenientstore
Trying to understand below;
NR==1||NR==3{li=$0"|"li} If it is first or third line, then concatenate that row data with value in variable li and store it in variable li.
Quote:
so value becomes 3rdline|1stline <-- separated by | ?
You are correct.
$0 contain the current line read from the file.
Let us consider the following file
For first line, li="abc" "|" ""
For the third line, li="ghi" "|" "abc|"