I want to get the number of files (included directories) contained in the root of a 7z archive, but the 7z command on Linux dont bring a simple way to only get the number and noting else.For example I have the 7zarchive.7z file witch contain archive.tar and archive.gzip. Then, 7z l 7zarchive.7z print me the following verbose lines:7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18p7zip Version 9.20 (locale=fr_FR.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)Listing archive: 7zarchive.7z--Path = 7zarchive.7zType = 7zMethod = LZMASolid = +Blocks = 1Physical Size = 495Headers Size = 184    Date      Time    Attr         Size   Compressed  Name------------------- ----- ------------ ------------  ------------------------2016-03-14 22:43:10 ....A        20480          311  archive.tar2016-03-14 23:04:01 ....A          163               archive.gzip------------------- ----- ------------ ------------  ------------------------                             20643          311  2 files, 0 foldersIn the right bottom, you can see 2 files, 0 folders, so I want to get the sum of number of folders and number of files.For this, I try the flowing hideous command:bash7z l 7z l *.7z  | tail -1 | sed -e 's/.* \([0-9]*\) files\, \([0-9]*\) folders/\1 \2/' -e 's/\([0-9]*\) \([0-9]*\)/\$(( \1 + \2))/'  | tail -1 | sed -e 's/.* \([0-9]*\) files\, \([0-9]*\) folders/\1 \2/' -e 's/\([0-9]*\) \([0-9]*\)/\$(( \1 + \2))/'tail extract the last line;The first sed expression extract the numbers before the words files and folders.The second sed expression formate it to be printed like this $(( <first number> + <second number>)).So, I really obtain the output $(( 2 + 0)), but I want it to be executed to get only the result (2) and not the command to calculate the result.So, there is a way to do this, or, at list, a more simple way to get the number of files contained by a 7z archive?
How to get number of files in a 7z
shell script;7z;sparse files
I finally find it, it was more simple that I imagine: 7z l -slt <nameof archive> | grep -c 'Path = [^/]*$'.