Linux WC -l statistics

The demand now is:

wc -l /home/logs/Xxx.txt how the statistical results are not displayed in the file path, namely the numerical as in statistical results

Started by Kathie at February 03, 2016 - 6:40 PM

wc -l /home/logs/xxx.txt | awk '{print $1}'

Posted by Luther at February 05, 2016 - 7:31 PM

wc -l </home/logs/xxx.txt

Posted by Kris at February 07, 2016 - 8:04 PM




Process process=null;
try{
process=Runtime.getRuntime().exec(cmd);
}catch(IOException e) {
logger.info("linux error:",e);
}
InputStreamReader reader = new InputStreamReader(process.getInputStream());
BufferedReader bufferedReader = new BufferedReader(reader);
String str=null; int count=0;////////////////////////////////
try{
str=bufferedReader.readLine();
}catch(IOException e1) {
logger.info("readLine error",e1);
}
logger.info("cmd1=="+cmd+",result="+str);
try{
bufferedReader.close();
reader.close();
}catch(IOException e) {
logger.info("close error",e);
}finally{
if(bufferedReader!=null){
try {
bufferedReader.close();
}catch(IOException e) {
logger.info("finally close bufferedReader error",e);
}
}
if(reader!=null){
try {
reader.close();
}catch(IOException e) {
logger.info("finally close reader error",e);
}
}
}
return count;
Why only second order result have value?

Posted by Kathie at February 08, 2016 - 9:01 PM

Sink?

Posted by Kathie at February 17, 2016 - 9:26 PM

Methods 1:
In Java code, a single quotes Linux command into two single quotation marks (not double quotation marks).

Methods 2:
Using the array, reference

Posted by Kris at January 01, 2017 - 6:38 PM

In Java code, a single quotes Linux command double quotation marks

Posted by Phil at January 07, 2017 - 6:23 PM