Hello,
i am using wc in shell scripts
the exact command is:
wc FILE | cut -d -f 2
it usually works but sometimes wc outputs the result in a different
formatting, that is, I have to do a cut -d -f 3 to get the wc.
This is not very convenient that the wc program shall not return
Pádraig Brady a écrit :
Iram CHELLI wrote:
Hello,
i am using wc in shell scripts
the exact command is:
wc FILE | cut -d -f 2
You probably want to squeeze adjacent blanks:
wc FILE | tr -s '[:blank:]' ' ' | cut -d' ' -f2
cheers,
Pádraig.
Thank you this is great.
Cheers,
Iram
Bob Proulx a écrit :
Iram CHELLI wrote:
wc FILE | cut -d -f 2
it usually works but sometimes wc outputs the result in a different
formatting, that is, I have to do a cut -d -f 3 to get the wc.
The output format for the wc on different systems will produce a
differing number
Pádraig Brady a écrit :
Pádraig Brady wrote:
You probably want to squeeze adjacent blanks:
wc FILE | tr -s '[:blank:]' ' ' | cut -d' ' -f2
Note you might wonder why cut doesn't support -d'[:blank:]'
to auto skip runs of horizontal whitespace. Details here: