I want to xheck if a file exists that uses wildcards as only the partial filename is known using the test Command, and when it exists then output just the number of lines in the file... do not include the filename. Then this output, is it captured by the CommandOutput or the ReturnValue as I want to use this value in another program?
Code:
test -e /logs/error_logs/*PROC* && wc -l /logs/error_logs/*PROC* || echo No
When a file exists, this will display the #line + filename, i.e.:
650 logs/error_logs/03_2017_PROCESSED.log
I just want 650.
I tried
test -e /logs/error_logs/*PROC* && wc -l < /logs/error_logs/*PROC* || echo No
But it displays the following message:
sh: /logs/error_logs/*PROC*: No such file or directory
and returns No
.
TIA