[#] Wyświetlenie liczby znaków przed linią

( Ostatnio zmieniony wt., 17/06/2008 - 14:02 )
 
#!/bin/bash
# print each line in file prefixed by it's line length

for file in "$@"; do
   echo -e "\nFILE: $file"
   awk '{ printf( "%5d: %s\n", length( $0 ), $0 ) }' $file
done

exit 0

przykładowy wynik:

FILE: line_length.sh
    9: #!/bin/bash
   54: # print each line in file prefixed by it's line length
    0:
   20: for file in "$@"; do
   26:    echo -e "\nFILE: $file"
   58:    awk '{ printf( "%5d: %s\n", length( $0 ), $0 ) }' $file
    4: done
    0:
    6: exit 0
5
Twoja ocena: Brak Średnio: 5 (1 vote)