Search code examples
bashgnu

Output in one number


Hello I have a task to count the number of symbolic links (not regular files nor directories etc.) in directory /bin having b as the first letter of their names.

>  find /bin -name "b*" -type l  -printf l  > list.txt

But it outputs

1111

What should I do to change the output to one number (I mean 4) insted of these four 1?


Solution

  • To count correctly also symbolic links with line breaks:

    find /bin -name "b*" -type l -printf "l" | wc -c >list.txt