Dear UNIX community,
I would like to to count characters from a specific row and have them displayed line-by-line.
I have a file called testAwk2.csv which contain the following data:
rabbit penguin goat
giraffe emu ostrich
I would like to count in the middle row individually line by line and append the result to the end of each line so the final result appears as follows:
rabbit penguin goat 7
giraffe emu ostrich 3
I have tried the following:
awk '{print $2, wc -m}' testAwk2.csv
Result:
penguin 0
emu 0
awk '{print $2 | "wc -m"}' testAwk2.csv
Result:
12
I thought the above code would produce something like:
penguin 7
emu 3
But it didn't:wall:
As you can see from the above code that I have not attempted to append a character count to the end of the line and instead have tried to concentrate in displaying the count for the individual rows.
Any suggestions or tips would be received gladly.
Many thanks,
vnayak