bug#70860: Add an option to remove filenames for wc util
Laurent Lyaudet <[email protected]> Fri, 17 Apr 2026 19:42:00 +0200
| Newsgroups | gmane.comp.gnu.core-utils.bugs |
|---|---|
| Message-ID | <CAB1LBmsH7XH_t7D=wvmR3FeHRzvMwjuU7tmr6j8pX2zM=pGMRQ@mail.gmail.com> |
Le ven. 17 avr. 2026 à 19:24, Paul Eggert <[email protected]> a écrit : > > On 2026-04-17 10:20, Laurent Lyaudet wrote: > >> Not a fair comparison. The fair comparison is: > >> > >> lines=$(wc -ln "$file") > >> > >> versus: > >> > >> lines=$(wc -l <"$file") > >> > > Still not a fair comparison. > > Sure it is, in the context of your earlier example. > > > A fair comparison can be: > >>>> for file in "${files[@]}"; do > >>>> lines=$(wc -l <"$file") && > >>>> printf '"%s" contains %d lines\n' "$file" $lines > >>>> done > > versus: > > lines=$(wc -ln -- "${files[@]}") > > Those are not equivalent, so it's not a fair comparison. > > At this point I'll let you have the last word; we're not making progress. Ok, if I can have the last word. Is that equivalent?: lines="" for file in "${files[@]}"; do lines+=$(wc -l <"$file") lines+=$'\n' done > versus: lines=$(wc -ln --total=never -- "${files[@]}") And that?: declare -i total=0 lines="" lines_current=0 for file in "${files[@]}"; do lines_current=$(wc -l <"$file") lines+="${lines_current}" lines+=$'\n' ((total+=lines_current)) done lines+="${total}" lines+=$'\n' > versus: lines=$(wc -ln -- "${files[@]}")