我在使用 awk 时遇到问题。从作为参数给出的每个文件中打印长度至少为 10 的行数。此外,打印该行的内容,除了前 10 个字符。在文件分析结束时打印文件的名称和打印的行数。
这是我到目前为止所做的:
{
if(length($0)>10)
{
print "The number of line is:" FNR
print "The content of the line is:" substr($0,10)
s=s+1
}
x= wc -l //number of lines of file
if(FNR > x) //this is supposed to show when the file is over but it's not working
{ //I also tried if (FNR == 1) - which means new file
print "This was the analysis of the file:" FILENAME
print "The number of lines with characters >10 are:" s
}
}
这会打印文件的名称和每行至少有 10 个字符的行数,但我想要这样的东西:
print "The number of line is:" 1
print "The content of the line is:" dkhflaksfdas
print "The number of line is:" 3
print "The content of the line is:" asdfdassaf
print "This was the analysis of the file:" awk.txt
print "The number of lines with characters >10 are:" 2