print number of lines and words in a single line with one spacing in shell scripting [closed]
Clash Royale CLAN TAG#URR8PPP
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?
text-formatting wc
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.
add a comment |
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?
text-formatting wc
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
add a comment |
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?
text-formatting wc
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?
text-formatting wc
text-formatting wc
edited Jan 21 at 10:21
Jeff Schaller
41k1056131
41k1056131
asked Jan 21 at 2:41
PATTAPU VENKATA SANDEEPPATTAPU VENKATA SANDEEP
41
41
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.
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
add a comment |
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
7
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
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
answered Jan 21 at 18:25
RalfFriedlRalfFriedl
5,4103925
5,4103925
add a comment |
add a comment |
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