I have some troubles removing the string between the first space \s and the first tab \t of  a text file (the tab should be kept):sample input:col1_frame1 unimportant    a b    cexpected output for sample:col1_frame    a b    cI tried with sed 's/ .*\t/\t/' but I got a wrong output: my output for sample (using previous sed):col1_frame    c
sed replace first occurrence of space-tab pattern
text processing;sed;replace
It's because .* will match to anything (as it is the regular expression wildcard) and can and will then be expanded as much as possible until the last tab seen (and encompassing any other tabs in between).  What you want is [^\t]* which will match any string not containing a tab, so combined your call to sed should look like this: sed 's/ [^\t]*\t/\t/'