0

When I am using wc -lw filename, I am getting output separated into two spaces. But I want only one space separated. How to do this?

1
  • 7
    this sounds like an XY problem ..... you want help with what you consider to be a solution to an unknown problem, when in fact, you should be asking for help with the original problem .......... why do you need to have only one space between the output fields? – jsotola Jan 21 '19 at 2:54
1

Use

echo $(wc -wl < filename)

or

echo $(wc -wl filename)

depending on whether you want the filename included. The $() will parse the output of the wc command into words separated by one or more spaces (or tabs). The effect for your case is that multiple spaces will be replaced by a single space.

Not the answer you're looking for? Browse other questions tagged or ask your own question.