D
D
Daniel Literate2016-04-09 00:11:14
bash
Daniel Literate, 2016-04-09 00:11:14

How to remove all characters after the first space using BASH + sed?

There is a line contained in the variable:
24kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.722941%
How to remove everything after the first space using sed? Those. leave 24kB.
Nubian question, but there is no urine to think.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2016-04-09
@Fuckoff95

you can get by with just bash: ${str%% *}
ideone.com/zVWyWA

S
Shetani, 2016-04-09
@Shetani

Not sed, of course, but...

echo "24kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.722941%" | awk -F' ' '{print $1;}'

P
Pavel Selivanov, 2016-04-09
@selivanov_pavel

Another option:echo "line with spaces" | cut -d' ' -f1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question