Timeline for How do I use cut to separate by multiple whitespace?
Current License: CC BY-SA 3.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 26, 2021 at 18:35 | comment | added | Thomas Ahle |
Thanks, I now have alias split = "sed 's/\s\s*/ /g' |cut -d ' ' -f " in my bashrc.
|
|
| Jun 20, 2020 at 2:33 | comment | added | rubo77 | So the right option for columned input into cut would be -c35-38 | |
| Sep 1, 2016 at 8:57 | comment | added | Gilles 'SO- stop being evil' |
@rubo77 If your sed supports it, that is. It's supported by GNU and BusyBox but not by e.g. BSD or Solaris. POSIX specifies + and ? in ERE but leaves \+ and \? in BRE undefined.
|
|
| Sep 1, 2016 at 8:29 | comment | added | rubo77 |
a bit shorter with + instead of *: cat test | sed 's/[^.0-9]\+/:/g' | cut -d : -f 6
|
|
| Aug 11, 2015 at 22:15 | history | rollback | Stéphane Chazelas |
Rollback to Revision 1
|
|
| Aug 11, 2015 at 22:13 | history | edited | Stéphane Chazelas | CC BY-SA 3.0 |
tr -s is the usual way there.
|
| Jan 18, 2014 at 0:30 | vote | accept | rubo77 | ||
| Jan 31, 2020 at 20:26 | |||||
| Jan 18, 2014 at 0:15 | vote | accept | rubo77 | ||
| Jan 18, 2014 at 0:30 | |||||
| Jan 18, 2014 at 0:13 | comment | added | Gilles 'SO- stop being evil' |
@rubo77 Works for me. The first two examples do exactly what you ask in your title. Or did you want to strip off the unit as well? In that case, add | sed 's/ .*//' at the end of the first two examples. Of course there are many other ways to do it.
|
|
| Jan 18, 2014 at 0:08 | comment | added | rubo77 | yes, sure only the numbers, but only your 3rd example works correctly | |
| Jan 18, 2014 at 0:02 | history | answered | Gilles 'SO- stop being evil' | CC BY-SA 3.0 |