wc -l only returns one number.
On Wed, 17 Feb 2021, Linux for blind general discussion wrote:
the "wc" command is returning more than one word, is the problem with "let".
you don't need the "let" anyway, so:
cj=`wc -l chk-jenux.log`
would be enough. but if you want only the count of lines, you either have to
1: isolate the first word from "wc" (the line count):
realcj=${cj%% *}
or
2: do the "wc" without a file name:
cj=`cat chk-jenux.log | wc -l`
note that the first example has a few failure modes, although there are endless
other ways to isolate a given word from a multi-word string. i've always
used the second example.
On Tue, Feb 16, 2021 at 11:08:58AM -0500, Linux for blind general discussion wrote:
I think I need a better shell.
I wanted to get a line count into a variable and bash doesn't like what
I'm doing to make that happen. The code is:
let "cj=`wc -l chk-jenux.log`"
_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/blinux-list