grep: match all characters up to (not including) first blank space

You are putting quantifier * at the wrong place.

Try instead this: –

grep '^[^\s]*' text1.txt > text2.txt

or, even better: –

grep '^\S*' text1.txt > text2.txt  

\S means match non-whitespace character. And anchor ^ is used to match at the beginning of the line.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)