Dec 4, 2009 #1 satpati Technical User Dec 4, 2009 2 FR Dear all, I am a beginner of awk. my input file is : 1 2 3 I want to multiply each element of the columns so that my output will be 1*2*3 = 6 How can i do this using awk. thanks regards
Dear all, I am a beginner of awk. my input file is : 1 2 3 I want to multiply each element of the columns so that my output will be 1*2*3 = 6 How can i do this using awk. thanks regards
Dec 4, 2009 #2 feherke Programmer Aug 5, 2002 9,540 RO Hi I guess it would be useless to ask you what have you tried so far. Code: awk 'BEGIN{m=1}{m*=$0;printf"%s%s",(NR>1?"*":""),$0}END{print"="m}' /input/file Tested with [tt]gawk[/tt] and [tt]mawk[/tt]. Feherke. http://free.rootshell.be/~feherke/ Upvote 0 Downvote
Hi I guess it would be useless to ask you what have you tried so far. Code: awk 'BEGIN{m=1}{m*=$0;printf"%s%s",(NR>1?"*":""),$0}END{print"="m}' /input/file Tested with [tt]gawk[/tt] and [tt]mawk[/tt]. Feherke. http://free.rootshell.be/~feherke/
Dec 4, 2009 Thread starter #3 satpati Technical User Dec 4, 2009 2 FR Dear feherke, Thank you very much. I apologizes for the very simple query. Thanks again regards satpati Upvote 0 Downvote
Dear feherke, Thank you very much. I apologizes for the very simple query. Thanks again regards satpati