Input data
Output Required
Tried this but not giving right results:
nawk -F"|" '{for (i=1;i<=NF;i++) print $NF}' filename
Please help me fix this. And also explain the logic how you did it so, I can do it next time.
Thanks for your help.
Input data
Output Required
Tried this but not giving right results:
nawk -F"|" '{for (i=1;i<=NF;i++) print $NF}' filename
Please help me fix this. And also explain the logic how you did it so, I can do it next time.
Thanks for your help.
echo 'a|b|c' | tr '|' '\n'
echo 'a|b|c' | awk -F'|' -v OFS='\n' '$1=$1'
You weren't too far off. Replace the $NF
with $i
(which means print the field pointed to by the loop variable instead of printing the last field repeatedly).