Tag Info

New answers tagged

1

You could use this instead: for c in {A..Z}; do echo -n "$c: " tr ' ' '\n' < dico.txt | grep $c | wc -l done It works as follows: The for loop runs through each character from A to Z. tr replaces all spaces with newlines, so every word has its own line. Then grep searches for the character in the word an prints it if the character is found. wc ...


0

Is it helps? #!/bin/bash tr ' ' '\n' < "$1" | sort -u > my.tmp for letter in {A..Z} do printf "Words with %c : " $letter grep -iwc "\w*$letter\w*" my.tmp echo done rm my.tmp


1

wc can provide both byte and line counts: find /directory/ -type f -exec wc -l -c {} + Using find is also preferable to a wildcard argument (stat ... directory/*), because the latter will fail when there are too many files in the directory for the names to fit in a single command.


3

You are almost there. find directory -type f -exec wc -lc {} + will get file name, line count, and character count. Strictly speaking, -c (a.k.a. --bytes) is documented as counting bytes, which is probably what you want.   There is also a -m (a.k.a. --chars) option for counting “characters”.  From the choice of the m option letter, I guess this counts ...


0

wc -c -l file1 file2 ... answers must be >= 30 characters long :)


0

for i in 'find \directory-name\ -type f' do echo "Printing line count and size of $i" cat $i | wc -l du -sh $i done I think this will help you in getting what you want.


2

If you use wc -l as you did with a file as argument you get something like line-count file-name which is an inappropriate format for the test operator. If you want the line count alone let wc read the file from standard input... LINE_COUNT=$( wc -l < "${LOG_DIR}/file_transaction.log" )


1

Check the output of wc -l ${LOG_DIR}/file_transaction.log. It will be of the form: 1234 .../file_transaction.log Instead, use: wc -l < ${LOG_DIR}/file_transaction.log



Top 50 recent answers are included