i got a file (books.txt)
12 A
15 B
And i want to output:
Group allocation
Group A: 12 books
Group B: 15 books
..
End List
i know how to reverse the two fields by using
awk {print $2,$1} books.txt
Im having problems outputting what i wanted using awk
so far i got:
{print "Group", $2,":",$1,"books"}
1) put a space between your open and closeing {}
2) in my experiance you dont need the , to seperate variables.
so just try { print "Group" $2":" $1 "books" }
if this dosent work what is the error you are getting.
hi there,im so so close to what i want to do.i have managed to acheive what i wanted but want to add something really small.
heres what i have done:
aspasia$ awk 'BEGIN{N=0;print "Group Allocation"} {N=N+1;print $2,$1} {print "End of List"}' numbers.txt
this prints out:
Group Allocation
A 20
End of List
B 9
End of List
C 11
End of List
I just want the End of List at the bottom.Not between each line.
awk is not my strong suit. hopefully you can figure it out.
That N variable serves no purpose.
awk 'BEGIN {print "Group Allocation"} {print $2,$1} END {print "End of List"}' numbers.txt
cheers guys.much appreciated.