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?

closed as too broad by G-Man, msp9011, Anthony Geoghegan, Mr Shunz, Archemar Jan 22 at 14:53

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 at 2:54


echo $(wc -wl < filename)


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.