如何在unix的10位数字末尾附加字数统计 [英] How to append the word count at the end of 10 digit number in unix
本文介绍了如何在unix的10位数字末尾附加字数统计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在文件末尾显示该文件的行数作为预告片.
我有0000000000
(10 0),所以如果行数为2
,则字符串应为0000000002
,如果文件中的行数为120
,则字符串应为0000000120
.我需要在文件末尾将此字符串显示为预告片.请帮助如何在UNIX中完成此操作.
I need to display the line count of the file at the end of the file as a trailer.
I have 0000000000
(10 0's) , so if the line count is 2
then the string should be 0000000002
, if the number of lines in the file are 120
then string should be 0000000120
. I need to display this string at the end of the file as a trailer. Please help how this can be done in unix.
推荐答案
您可以尝试awk
awk '{print}END{printf("%010i\n", NR)}' file
这篇关于如何在unix的10位数字末尾附加字数统计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文