this will work for you:
awk '{$0=NF FS $0}7' file
Вопрос
I have several very large text files and would like to append the count of numbers following by a space in front of each line. Could anyone kindly suggest how to do it efficiently using Awk?
Input:
10 109 120 200 1148 1210 1500 5201
9 139 1239 1439 6551
199 5693 5695
Desired Output:
8 10 109 120 200 1148 1210 1500 5201
5 9 139 1239 1439 6551
3 199 5693 5695
Решение 2
this will work for you:
awk '{$0=NF FS $0}7' file
Другие советы
You can use
awk '{print NF,$0}' input.txt
It says print number of field of the current line NF
separated by current field separator ,
which in this case is a space then print the current line itself $0
.