I want to count how many rows are in one file with defined length to show.
In normal case example:
file:
2423
546
74868
cat file|wc -l
will show the result: 3
.
But I want to defined length of the numbers for example to have 10 symbols and to show:
0000000003
if there are 100 lines to be:
0000000100
I think that you want something like this:
The format specifier
%010d
means print 10 digits, padded with leading 0s.As a bonus, in using
<
to pass the contents of the file via standard input, I have saved you a "useless use ofcat
" :)If I understand your comment correctly, you can do something like this:
Here I have added some additional text to the format specifier and used an arithmetic context
$(( ))
to add one to the value of the line count.