Sed
sed 's/\s.*$//'
Grep
grep -o '^\S*'
Awk
awk '{print $1}'
As pointed out in the comments, -o
isn't POSIX; however both GNU and BSD have it, so it should work for most people.
Also, \s
/\S
may not be on all systems, if yours doesn't recognize it you can use a literal space, or if you want space and tab, those in a bracket expression ([...]
), or the [[:blank:]]
character class (note that strictly speaking \s
is equivalent to [[:space:]]
and includes vertical spacing characters as well like CR, LF or VT which you probably don't care about).
The awk
one assumes the lines don't start with a blank character.
cut
, I can't tell if it will accept any sort of regex syntax. Do you have any idea whether or not it will, and if so, which type(s)? sry to bother and thanks. – Nate T Sep 18 '21 at 13:40