New answers tagged


No, ".pdf" macthes way too much, e.g foo.pdfa and bpdf. Furthermore, even if you don't have files wrongly matching, wc without options outputs the number of lines, words and bytes in the input, so you would get two numbers more than you're interested in. If you want grep in the mix, you could do ls | grep -E "\.pdf$" | wc -l, but unless you have a lot of ...


You should use ls | grep ".pdf" | wc -l The -l parameter will count only the number of resulted lines, while without the -l you would get other counts as well, like newline, word, and byte count. Note that this will count filenames (and folders as well) which contain the ".pdf" chain of characters. To count only files ending with .pdf, you'd better ...


Your shell should be able to do the filtering: ls *.pdf | wc -l or you have to make sure you match the end of filenames: ls | grep "*\.pdf$" | wc -l (notice the dollar sign). Note: both of these will also match directories ending in ".pdf", if any. Note 2: ls should behave as if you gave it option -1 as soon as you pipe its output. Otherwise, add ...


You can do it with just find and awk: find . -type f -name '*.php' -size +1000c -exec awk ' FNR > 1 {nextfile} length >= 1000 {print FILENAME}' {} + The awk script skips to next file after the first line of every file. It prints the filename of the current file if the current line is >= 1000 characters long.

Top 50 recent answers are included