[英]How to find the number of lines of the files inside a tar file without extracting
I have a tar file, which has lots of csv files in it. 我有一个tar文件,其中有很多csv文件。 Is there a way to find the number of lines in each csv file without extracting it in linux? 有没有一种方法可以找到每个csv文件中的行数,而无需在linux中提取它?
I tried 我试过了
for file in $(tar -tf "$tarfile")
do
NL=`wc -l < "$file"`
done
But it gives error: "No such file or directory". 但是它给出了错误:“没有这样的文件或目录”。
Can anyone help please. 谁能帮忙。
Try this: 尝试这个:
for file in $(tar -tf "$tarfile")
do
NL=$(tar Oxf "$tarfile" "$file" | wc -l)
done
Oxf
extracts the specified file to stdout. Oxf
将指定的文件提取到stdout。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.