简体   繁体   English

unix命令上的wc -l返回值

[英]wc -l on unix command return value

I have a program that when I run it it takes away comments and blank lines etc. 我有一个程序,当我运行它会删除注释和空白行等。

/home/user/Development/loc -c /vobs/unitTestStub/works.h

And it prints out comment stripped code like 它打印出注释剥离的代码,例如

#ifndef works_H
#define works_H
#include <fc.h>
#include <stdlib.h>
#include <unistd.h>
...

When I run a 当我运行一个

wc -l /home/user/Development/loc -c /vobs/unitTestStub/works.h

It prints out 打印出来

  56 1349 /home/user/Development/loc
  27  443 /vobs/unitTestStub/works.h
  83 1792 total

But I only want wc -l on what the first line returns. 但是我只想在第一行返回的内容上使用wc -l。 For example loc prints out a string that is only 15 lines long and wc -l says that its 27 lines long so this needs to be sorted out. 例如,loc打印出只有15行长的字符串,而wc -l表示其27行长,因此需要进行排序。

Can anyone please give me how to run wc -l on what the command 谁能告诉我如何在命令上运行wc -l

wc -l /home/user/Development/loc -c /vobs/unitTestStub/works.h

prints out? 打印出来?

Thanks alot in advance =) 非常感谢=)

Br Anders. Br Anders。

使用管道进行IO重定向:

$> /home/user/Development/loc -c /vobs/unitTestStub/works.h | wc -l

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM