I am trying to get total number of lines in all of the files in the current working directory
in order to do this i tried this following command
wc -l * | tail -1
But this command also returns me the directories..
my output is like
wc: Folder1: Is a directory
wc: Folder2: Is a directory
wc: Folder3: Is a directory
1714 total
I want only the return number(1714 in this case) in the output. And then i will assign it into variable to use it later.
How can i truncate the directory lines?
Later on i may want to use this command with relative path... I don't know how to call wc -l command with relative directory parameter either?
Thanks..
You can use:
wc -l * 2>/dev/null
Better command would be using find
to get only 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}'
find -mindepth 1 -maxdepth 1 -type f -exec cat {} ";" | wc -l
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.