Sunday 15 May 2011

linux - How to truncate Directory lines in "wc -l" command? -



linux - How to truncate Directory lines in "wc -l" command? -

i trying total number of lines in of files in current working directory

in order tried next command

wc -l * | tail -1

but command returns me directories..

my output

wc: folder1: directory wc: folder2: directory wc: folder3: directory 1714 total

i want homecoming number(1714 in case) in output. , assign variable utilize later.

how can truncate directory lines?

later on may want utilize command relative path... don't know how phone call wc -l command relative directory parameter either?

thanks..

you can use:

wc -l * 2>/dev/null

better command using find files:

or else:

find . -maxdepth 1 -type f -print0 | xargs -0 -i % cat % | wc -l

or else:

wc -l --files0-from=<(find . -maxdepth 1 -type f -print0) | awk 'end{print $1}'

linux bash shell terminal fedora

No comments:

Post a Comment