New answers tagged

2

You can try this one using find and grep : find . -type f -name '*.php' -exec grep '.\{1000\}' {} +


7

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.


4

Use tee (here assuming a system with support for /dev/fd/<n>): { lines=$(function_call 3>&- | tee -a /dev/fd/3 | wc -l) } 3>&1 if [ "$lines" -gt 1 ]; then do_stuff fi On Linux that has an odd implementation of /dev/fd/<n>, if stdout is redirected to a file, the output will be inserted at the end of that file even if the ...


1

Your question doesn't say where the previous known-good values come from. I'm going to assume you have a parallel tree to the content tree called ../oldcontent. Adjust to suit: #!/bin/bash echo "Checking directories for proper extensions" for d in documents media pictures other do nfc=$(find content/$d -type f | wc -l) ofc=$(find ../oldcontent/$d ...


0

The SunOS wc output matches the definitions of SYSVr4. I cannot see any real divergence to the POSIX standard. Even the build-in wc from ksh93 matches the SunOS output and a recent Solaris 11 even uses the wc library implementation from ksh93 with no change in the output. If your scripts have problems with the output from one or another wc implementation, ...


2

Actually, the behavior I see for Linux (and OSX) matches SunOS reasonably well, with some differences for the number of digits. HPUX follows the description in POSIX, which shows no leading blanks in the format: "%d %d %d %s\n", <newlines>, <words>, <bytes>, <file> You can imitate SunOS's format using awk #!/bin/sh wc () { ...


1

If you are not restricted to wc, you can filter out the numbers with a tool like sed and then count the words using wc. Given your text (in testfile) will give: $ sed -e s/[0-9]*//g testfile disobediently RESINY GRAPHICS lownesses prickers intractabiliti es villainously MINIS blinkering applicants TORPIDITIES subtexts apportioned carded ...



Top 50 recent answers are included