I use the command wc -l
count number of lines in my text files (also i want to sort everything through a pipe), like this:
wc -l $directory-path/*.txt | sort -rn
The output includes "total" line, which is the sum of lines of all files:
10 total
5 ./directory/1.txt
3 ./directory/2.txt
2 ./directory/3.txt
Is there any way to suppress this summary line? Or even better, to change the way the summary line is worded? For example, instead of "10", the word "lines" and instead of "total" the word "file".
Yet a
sed
solution!1. short and quick
As total are comming on last line,
$d
is the sed command for deleting last line.2. with header line addition:
Unfortunely, there is no alignment.
3. With alignment: formatting left column at 11 char width.
Will do the job
4. But if really your
wc
version could put total on 1st line:This one is for fun, because I don't belive there is a
wc
version that put total on 1st line, but...This version drop total line everywhere and add header line at top of output.
This is more complicated because we won't drop 1st line, even if it's total line.